0 bình luận về “VCT tính tổng a[1]^1+a[2]^2+…+a[n]^n”
uses crt; var a: array[1..100] of integer; i,n,tt: longint; Function lt(a,n:integer):longint; Var i:integer; kq:longint; Begin kq:=1; For i:=1 to n do kq:=kq*a; lt:=kq; End; begin clrscr; write (‘nhap so phan tu: ‘); readln (n); for i:=1 to n do begin write (‘nhap a[‘,i,’]: ‘); readln (a[i]); tt:=tt+lt(a[i],i); end; writeln (‘tong la: ‘,tt); readln; end.
uses crt;
var a: array[1..100] of integer;
i,n,tt: longint;
Function lt(a,n:integer):longint;
Var i:integer; kq:longint;
Begin
kq:=1;
For i:=1 to n do kq:=kq*a;
lt:=kq;
End;
begin
clrscr;
write (‘nhap so phan tu: ‘); readln (n);
for i:=1 to n do
begin
write (‘nhap a[‘,i,’]: ‘); readln (a[i]);
tt:=tt+lt(a[i],i);
end;
writeln (‘tong la: ‘,tt);
readln;
end.
program tinhtong;
uses crt;
var A:array[1..100] of integer;
n,i:byte;
S:int64;
function mu(k:integer; m:byte):int64;
var l:byte;
begin
mu:=1;
for l:=1 to m do mu:=mu*k;
end;
BEGIN
clrscr;
write(‘Nhap so luong phan tu n: ‘); readln(n);
S:=0;
for i:=1 to n do
begin
write(‘A[‘,i,’]= ‘); readln(A[i]);
S:=S+mu(A[i],i);
end;
write(‘Tong la: ‘,s);
readln;
end.