uses crt;
var day:array[1..10000] of longint;
a,b,s,c,i,n:longint;
ch:char;
procedure chuoi;
begin
Gotoxy(1,20);write('Day so da nhap: ');
for i:=1 to n do
begin
write(day[i],', ');
end; end;
begin
clrscr;
write('Nhap so phan tu cua day: ');readln(n);
for i:=1 to n do
begin
write('Nhap gia tri cho phan tu ',i,': ');
readln(day[i]);
end;
repeat
(* Giao dien *)
clrscr;
Gotoxy(1,1);
writeln('Hay chon so thu tu thich hop de bat dau chuong trinh (esc de thoat)');
gotoxy(1,20);writeln('1: Dua ra cac so nguyen am trong day va vi tri cua chung ');
writeln('2: Tinh tong va dem cac so le trong day');
writeln('3: Tinh trung binh cong cua cac so la boi cua 3');
writeln('4: Tinh so cac so chan trong day va tong cua chung');
writeln('5: Nhap vao 1 day so nguyen (k), tim xem k co trong day khong');
writeln('6. Thoat');
gotoxy(1,20);
ch:=readkey;
case ch of
'1': Begin
clrscr;
chuoi;
gotoxy(1,1);
writeln('Dua ra cac so nguyen am va tim vi tri cua chung trong day');
gotoxy(1,5);
a:=0;
for i:=1 to n do
if day[i] < 0 then
begin
a:=a+1;
writeln(a,'. So am ',day[i],' Vi tri thu ',i,' trong day');
end;
end;
'2': begin
clrscr;
chuoi;
gotoxy(1,1);
writeln('Tinh tong va dem cac so le trong day');
s:=0; a:=0;
for i:=1 to n do
if day[i] mod 2 <> 0 then
begin
a:=a+1;
s:=s+day[i];
end;
writeln('Trong day co ',a,' so le. Tong cua chung bang ',s);
end;
'3': begin
clrscr;
chuoi;
gotoxy(1,1);
writeln('Tinh tong trong binh cong cac so la boi cua 3');
a:=0;s:=0;
for i:=1 to n do
if day[i] mod 3 = 0 then
begin
a:=a+1;
s:=s+day[i]
end;
writeln('Trung binh cong cua cac so la oi cua 3 la: ',s/a:2:2);
end;
'4': begin
clrscr;chuoi;gotoxy(1,1);
writeln('Tinh tong va dem cac so chan trong day');
s:=0; a:=0;
for i:=1 to n do
if day[i] mod 2 = 0 then
begin
a:=a+1;
s:=s+day[i];
end;
writeln('Trong day co ',a,' so chan. Tong cua chung bang ',s);
end;
'5': begin
clrscr;
chuoi;
gotoxy(1,1);
writeln('Nhap vao mot so nguyen (k) bat ki va tim xem chung co trong day khong?');
write('Nhap 1 so tu nhien k bat ki: ');
readln(b);
write('So k nam o vi tri: ');
a:=1;
for i:=1 to n do
if day[i]=b then
begin
write(i,' , ');
a:=0;
end;
writeln;
if a=0 then writeln('So ',b,' (k) ton tai trong day') else writeln('So ',b,' (k) khong ton tai trong day');
end;
end;
readkey;
until (ch=#27) or (ch='6');
end.