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 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.
Var a:array[1..30] of integer;
i,n,d,max:integer;
Begin
Write('Nhap so luong phan tu cua mang ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
max:=a[1];
For i:=2 to n do
Begin
If a[i] > max then
Begin
max:=a[i];
d:=i;
End;
End;
Write('Phan tu lon nhat la ',max,' o vi tri ',d);
Readln;
End.
Bài 23
var a:array[1..1000] of integer;
i,n:integer;
s,tbc:real;
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;
tbc:=s/n;
writeln('Gia tri trung binh la ',tbc:10:2);
write('Cac so lon hon gia tri trung binh la: ');
for i:=1 to n do
if a[i] > tbc then write(a[i]:8);
readln
end.
var a:array[1..1000] of integer;
i,n,max:integer;
begin
write('n = ');readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
end;
max:=a[1];
for i:=2 to n do
if a[i] > max then max:=a[i];
for i:=1 to n do
begin
if max=a[i] then write(max,' o vi tri thu ',i);
break;
readln
end.
Câu 1:
uses crt;
var a:array[1..5]of integer;
max,i:integer;
begin
clrscr;
for i:=1 to 5 do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to 5 do
if max<a[i] then max:=a[i];
writeln(max);
readln;
end.
Câu 2:
uses crt;
var a:array[1..6]of integer;
min,i:integer;
begin
clrscr;
for i:=1 to 6 do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to 6 do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
uses crt;
var a:array[1..10]of integer;
i,n,max:integer;
begin
clrscr;
n:=10;
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];
writeln(max);
readln;
end.
Sửa đề: Tính tổng các phần tử trong mảng
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t);
readln;
end.
Câu 1:
uses crt;
var a:array[1..200]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln(t);
readln;
end.
Var a:array[1..30] of integer;
i,n,d,max:integer;
Begin
Write('Nhap so luong phan tu cua mang ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
max:=a[1];
For i:=2 to n do
Begin
If a[i] > max then
Begin
max:=a[i];
d:=i;
End;
End;
Write('Phan tu lon nhat la ',max,' o vi tri ',d);
Readln;
End.
Var a:array[1..30] of integer;
i,max,d:integer;
Begin
For i:=1 to 30 do
Begin
Repeat
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
Until a[i]<=255;
End;
max:=a[1];
d:=1;
For i:=2 to 30 do
If a[i] > max then
Begin
max:=a[i];
d:=i;
End;
Write('Phan tu lon nhat la ',max,' tai vi tri ',i);
Readln
End.
Program HOC24;
var a: array[1..1000] of integer;
i,n,max: integer;
begin
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
t:=a[1];
for i:=2 to n do if a[i]>max then max:=a[i];
writeln('So lon nhat trong mang la: ',max);
write('Vi tri cua cac phan tu do la: ');
for i:=1 to n do if a[i]=max then write(i,' );
readln
end.