Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
uses crt;
var j,tg,s,max,min,i,n:longint;
a:array[1..19] of longint;
s1:real;
begin
clrscr;
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
for i:=1 to n do
write(a[i],' ');writeln;
for i:=1 to n do
s:=s+a[i];
s1:=s/n;
writeln(‘Gia tri trung binh cua cac phan tu la: ‘,s1:0:0);
min:=a[1];max:=a[1];
for i:=2 to n do begin
if a[i]>max then max:=a[i];
if a[i]<min then min:=a[i];
write('Phan tu lon nhat la: ',max,' ','Phan tu nho nhat la: ',min); writeln;
for i:=1 to n do
if (a[i]<>0) and (a[i] mod 2=0) then write(a[i],' ');
readln
end.
program so_tu_nhien_chan;
uses crt;
var n,i:integer;
begin
clrscr;
write('Nhap n='); readln(n);
write('Cac so chan nho hon hoac bang ',n,' la: ');
for i:=2 to n do
if i mod 2=0 then write(i:4,' ;');
readln;
end.
uses crt;
var a:array[1..10]of integer;
i,t:integer;
begin
clrscr;
for i:=1 to 10 do readln(a[i]);
t:=0;
for i:=1 to 10 do t:=t+a[i];
writeln(t);
readln;
end.
Lời giải :
program hotrotinhoc ;
var a: array[1..32000] of integer ;
i,n,max : integer ;
begin
write('Nhap n='); readln(n);
writeln('Nhap gia tri cua cac phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:= 1 to n do if max<a[i] then max:=a[i];
write('So lon nhat la:',max');
readln
end.
var s,i,n:integer;
begin
Write('n = ');
While (n > 100) and (n < 1) then
Begin
write('Nhap sai, nhap lai ');readln(n);
End;
for i:=1 to n do
s:=s+i;
write('tong la: ',s);
readln;
end.
Uses crt;
Var i,n,x:integer;
s:array[1..10000] of integer;
Begin
clrscr;
Write('Nhap do dai cua day: ');readln(n);
for i:= 1 to n do
begin
write('So thu ',i,' = ');
readln(s[i]);
End;
Writeln('Cac so chinh phuong co trong day:');
for i:= 1 to n do
Begin
x:=trunc(sqrt(s[i]));
if sqr(x) = s[i] then write(s[i],' ');
end;
Readln;
End.
uses crt;
var n,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 3=0 then t:=t+i;
writeln(t);
readln;
end.