Source: https://ideone.com/cuQxiu (Pascal)
Chúc bạn học tốt nha
program an_danh;
uses crt;
var n,i,tong,luu,luu1,luu2: integer;
a: array [1..10] of longint;
begin
clrscr;
repeat
write('So phan tu cua day: ');readln(n);
if n > 10000 then
begin
write('Hay nhap so <= 10000');
delay(2000);
clrscr;
end;
until n <= 10000;
for i:= 1 to n do
begin
write('Phan tu thu ',i,': ');
luu1:= wherex; luu2:= wherey;
repeat
readln(a[i]);
if a[i] > 10000000 then
begin
write('Phap so <= 10^7');
delay(2000);
gotoxy(luu1,luu2);
clreol;
end;
until a[i] <= 10000000;
end;
tong:= 0;
for i:= 1 to n do
begin
if a[i] >= 0 then luu:= i;
tong:= tong + a[i];
end;
writeln('Chi so cua so hang duong cuoi cung ca day: ',luu);
write('Tong cac phan tu cua day: ',tong);
readln
end.
uses crt;
var a,b:array[1..10000]of longint;
i,n,dem,x,ln,t:longint;
begin
clrscr;
write('n='); readln(n);
if (n>0) and (n<=10000) then
begin
for i:=1 to n do
begin
repeat
write('a[',i,']='); readln(a[i]);
if a[i]>10000000 then writeln('vui long nhap lai');
until a[i]<=10000000;
end;
{-----------------------cau-1-------------------------}
dem:=0;
for i:=1 to n do
if a[i]>0 then
begin
dem:=dem+1;
b[dem]:=a[i];
end;
x:=b[dem];
ln:=0;
for i:=1 to n do
if x=a[i] then
begin
if ln<i then ln:=i;
end;
writeln('chi so cua hang duong cuoi cung trong day la: ',ln);
{--------------------------cau-2--------------------------}
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('tong cac phan tu trong day la: ',t);
end
else writeln('vui long nhap lai n');
readln;
end.