quá dễ
Bài 1:
program bai_1;
uses crt;
var a:array[1..100] of integer; n,i:longint;
tong1,tong2,tong3,tong4,tich1,tich2,tich3,tich4:integer;
begin
clrscr;
write('nhap so phan tu cua day la:'); readln(n);
For i:=1 to n do begin
write(a[',i,']=');
readln (a);
end;
tong1:=0; tich1:=0;
tong2:=0; tich2:=0;
tong3:=0; tich3:=0;
tong4:=0; tich4:=0;
For i:=1 to n do
if a mod 2=0 then begin
tong1:=tong1+a;
tich1:=tich1*a;
end
else begin
tong2:=tong2+a;
tich2:=tich2*a;
end;
For i:=1 to n do
if a>0 then begin
tong3:=tong3+a;
tich3:=tich3*a;
end
else begin
tong4:=tong4+a;
tich4:=tich4*a;
end;
write('Tong va tich cua cac so chan la ',tong1,',',tich1);
write('Tong va tich cua cac so le la ',tong2,',',tich2);
write('Tong va tich cua cac so duong la ',tong3,',',tich3);
write('Tong va tich cua cac so am la ',tong4,',',tich4);
readln;
end.
bài 2:
program bai_2;
uses crt;
var a:array[1..100] of integer;
d1,i,n:longint;
s:string;
Function cp(a:longint):boolean;
var i:longint;
begin
For i:=1 to a do
if i*i=a then begin
cp:=true;
exit;
end;
cp:=false;
end;
Function dx(s:string):boolean;
var i:longint; s1:string;
begin
s1:='';
For i:=length(s) downto 1 do s1:=s1+s;
dx:=(s1=s);
end;
begin
clrscr;
write('nhap so phan tu cua day la:'); readln(n);
For i:=1 to n do begin
write(a[',i,']=');
readln (a);
end;
d1:=0;
For i:=1 to n do
if cp(a) then begin
write(a:8);
inc(d1);
end;
if d1=0 then write('ko co so chinh phuong') else write('co tat ca ',d1,' so chinh phuong');
d1:=0;
For i:=1 to n do
begin
str(a,s);
if dx(s) then begin
write(s,',');
inc(d1);
end;
end;
if d1=0 then write('ko co so doi xung') else write('co tat ca ',d1,' so doi xung');
readln;
end.