Do bài hơi dài nên mk chỉ viết phần thân chương trình thôi nha
đề 1
Begin
write (' nhap n');
readln (n);
For i:= n downto 1 do write (i);
end.
đề 2
Begin
Write (' nhap N');
readln (n);
a:=0;
For i:= 1 to n do
begin
if i mod 2 <> 0 then a:= a+i;
end;
Write (' Tong cac so le la:', a);
de 3
Begin
Write (' nhap N');
readln (n);
a:=0;
for i:= 1 to n do
begin
if ((i>= 0) and (i mod 5 = 0)) then a:= a+i;
end;
Write (' TOng cac so nguyen duong chia het cho 5 la', a);
de 4
Begin
Write (' nhap so phan tu cua mang');
readln (n);
For i := 1 to n do
begin
Write (' Nhap so thu ', i);
readln (a[i]);
end;
Write (' Nhap 1 so bat ki');
readln (X);
m:= 0;
For i:= 1 to n do
begin
if a[i] = x then m:= m+1;
end;
Write (' So lan xuat hien cua ', x,' la: ', m );
readln;
end.
de 5
Begin
Write (' nhap so phan tu cua mang');
readln (n);
For i := 1 to n do
begin
Write (' Nhap so thu ', i);
readln (a[i]);
end;
Min:= a[1];
Max: a[1];
For i:= 1 to n do
begin
If a[i] > Max then max:= a[i];
If a[i] < min then min:= a[i];
end;
Writeln (' So lon nhat trong mang la', max);
Write (' So nho nhat trong day la', min);
readln;
end.
de 6
Begin
Write (' nhap so phan tu cua mang');
readln (n);
For i := 1 to n do
begin
Write (' Nhap so thu ', i);
readln (a[i]);
end;
am:= 0;
duong:= 0;
For i:= 1 to n do
begin
If a[i] > 0 then duong:= duong+ a[i] * a[i];
If a[i] < 0 then am := am + a[i] * a[i];
end;
Writeln (' tong cac so am la', am);
Writeln (' tong cac so duong la', duong);
readln;
end.