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.
program TimMaxMinCuaMang;
var
mang: array of integer;
n, i, max, min: integer;
begin
write('Nhap so phan tu cua mang: ');
readln(n);
setlength(mang, n);
writeln('Nhap cac phan tu cua mang:');
for i := 0 to n-1 do
begin
readln(mang[i]);
end;
max := mang[0];
min := mang[0];
for i := 1 to n-1 do
begin
if mang[i] > max then
max := mang[i];
if mang[i] < min then
min := mang[i];
end;
writeln('Phan tu lon nhat la: ', max);
writeln('Phan tu nho nhat la: ', min);
readln;
end.
Var a:array:[1..1000] of integer;
i,n,min,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];
min:=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];
end;
writeln('So lon nhat la ',max);
write('So nho nhat la ',min);
Readln
End.
a)
uses crt;
var a:array[1..100]of integer;
i,n,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
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.
b)
uses crt;
var a:array[1..100]of integer;
i,n,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,max,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(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('Gia tri lon nhat la: ',max);
writeln('Gia tri nho nhat la: ',min);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,h:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
h:=0;
for i:=1 to n do
if a[i] mod 2=0 then h:=h-a[i];
writeln(h);
readln;
end.
Làm như z có đg ko
Uses crt;
Var n,i: integer;
A: Array[1..1000] of integer;
Begin
clrscr;
Repeat
Write('Nhap n: '); Readln(n);
Until (n<103) and (n>0);
a)
For i:=1 to n do
begin
Write('Nhap phan tu A[',i,']= ');
Readln(A[i]);
end;
b)
Write('Cac phan tu chan co trong mang: ');
For i:=1 to n do
If A[i] mod 2=0 then write(A[i],' ');
writeln;
c)
Write('Cac phan tu le co trong mang: ');
For i:=1 to n do
If A[i] mod 2=1 then write(A[i],' ');
Readln
End.
Uses crt;
var i,n: longint;
a: array[1..103] of longint;
begin clrscr;
readln(n);
for i:=1 to n do read(a[i]); readln;
for i:=1 to n do if(a[i] mod 2=0) then write(a[i],' ');
for i:=1 to n do if(a[i] mod 2<>0) then write(a[i],' ');
readln;
end.
program mang;
uses crt;
var n,i,chan, le,max,min: Integer;
a:array[1..100] of integer;
begin
write('nhap so phan tu ');read(n);
for i:=1 to n do
begin
write('nhap so thu ',i); readln(a[i]);
end;
max:=a[1]; min:=a[1]; chan:=0;le:=0;
for i:=1to n do
begin
if a[i] > max then max:=a[i];
if a[i] < min then min:=a[i];
if a[i] mod 2 = 0 then chan:=chan+1
else le:=le+1;
end;
writeln('max la: ',max);
writeln('min la: ',min);
writeln('so phan tu chan: ',chan);
writeln('so phan tu le: ',le);
readln
end.