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 n,i,s,t,j,max:longint;a,b:array[1..100] of longint;tbc:real;
function snt(n:longint):boolean;
var j:longint;
begin
for j:=2 to trunc(sqrt(n)) do
if n mod j=0 then exit(false);
exit(n>1);
end;
begin
readln(N);
for i:=1 to n do
begin
read (a[i]);
if snt(a[i])=true then
begin
j:=j+1;
b[j]:=a[i];
end;
end;
t:=b[1];
max:=b[1];
for i:=2 to j do
begin
if b[i]>max then max:=b[i];
t:=t+b[i];
write(b[i]:4);
end;
tbc:=t/j;
writeln(S);
writeln(tbc);
writeln(max);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,max,t,min,dem1:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
max:=-32000;
for i:=1 to n do
begin
if a[i] mod 2=0 then
begin
dem:=dem+1;
if max<a[i] then max:=a[i];
end;
if dem=0 then writeln('Trong day khong co so chan')
else begin
writeln('So so chan la: ',dem);
writeln('So chan lon nhat la: ',max);
end;
t:=0;
for i:=1 to n do
if i mod 2=1 then t:=t+a[i];
writeln('Tong cac so o vi tri le la: ',t);
min:=maxint;
dem1:=0;
for i:=1 to n do
if a[i] mod 2<>0 then
begin
inc(dem1);
if min>a[i] then min:=a[i];
end;
if dem1=0 then writeln('Trong day khong co so le')
else writeln('So le nho nhat la: ',min);
readln;
end.
Uses crt;
var max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+a[i];
end;
max:=a[1];
min:=a[1];
for i:=1 to n do begin
if(max<a[i]) then max:=a[i];
if(min>a[i]) then min:=a[i];
end;
Writeln('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
readln;
end.
Uses crt;
var max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+a[i];
end;
max:=a[1];
min:=a[1];
for i:=1 to n do begin
if(max<a[i]) then max:=a[i];
if(min>a[i]) then min:=a[i];
end;
Writeln('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
readln;
end.
Bài 1
Var a:array:[1..1000] of integer;
i,n:integer;
s:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
s:=s+a[i];
End;
Write('Cac so vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
write('Tong cac so la ',s);
Readln
End.
Program HOC24;
var min,max,n,i: integer;
t: longint;
a: array[1..1000] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Cac so chan trong mang la: ');
for i:=1 to n do if a[i] mod 2=0 then write(a[i],' ');
writeln;
t:=0;
for i:=1 to n do if a[i] mod 2=1 then t:=t+a[i];
writeln('Tong cac so le la: ',t);
min:=a[1]; max:=a[1];
for i:=1 to n do
begin
if a[i]>max then max:=a[i];
if a[i] <max then max:=a[i];
end;
writeln('Gia tri lon nhat la: ',max);
write('Gia tri nho nhat la:' ,min);
readln
end.
Đúng là anh thành sứt, lên đây hỏi ạ.