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 i,n,a,b, uc,bcnn:integer ;
c:array[1..100] of integer;
{--- CTC tim UCLL hai so} function ucln(a,b:integer):integer;
var r:integer;
begin r:=a mod b;
while r<>0 do begin a:=b; b:=r; r:= a mod b;
end;
ucln:=b;
end;
{--- CTC chinh----} begin Write('n= ');
readln(n);
for i:=1 to n do begin write('c[',i,']=');
readln(c[i]);
end;
for i:= 1 to n do
Write(c[i]:3);
writeln;
uc:=ucln(c[1], c[2]);
bcnn:=(c[1]*c[2])div uc;
for i:=3 to n do begin uc:=ucln(uc,c[i]);
bcnn:= bcnn*c[i] div uc;
end;
Writeln('bcnn =',bcnn); readln; end.
var i,n,min,max:integer;
a:array[1..1000] of integer;
begin
Write('n=');read(n);
for i:=1 to n do
Read(a[i]);
i:=1;
max:=0;
min:=a[i];
while i<n do
Begin
if a[i] > max then max:=a[i];
if a[i] <min then min:=a[i];
i:=i+1;
end;
writeln('Gia tri LN la:',max);
writeln('Gia tri NN la:',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.
program TimMinMaxTrungBinh;
var
N, i, max, min, sum: integer;
a: array[1..50] of integer;
TB, minTB, maxTB: real;
begin
writeln('Nhap so nguyen duong N:');
readln(N);
sum := 0;
for i := 1 to N do
begin
write('Nhap so thu ', i, ': ');
readln(a[i]);
sum := sum + 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;
TB := sum / N;
minTB := TB;
maxTB := TB;
for i := 1 to N do
begin
if (a[i] < TB) and (a[i] < minTB) then
minTB := a[i];
if (a[i] > TB) and (a[i] > maxTB) then
maxTB := a[i];
end;
writeln('Gia tri lon nhat la: ', max);
writeln('Gia tri nho nhat la: ', min);
writeln('Gia tri trung binh la: ', TB:2:2);
if minTB = TB then
writeln('Khong co gia tri nao nho hon TB')
else
writeln('Gia tri nho nhat < TB la: ', minTB);
if maxTB = TB then
writeln('Khong co gia tri nao lon hon TB')
else
writeln('Gia tri lon nhat > TB la: ', maxTB);
readln;
end.
Var a:array:[1..100] of integer;
i,max:integer;
Begin
For i:=1 to 100 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];
write('So lon nhat la ',max);
Readln
End.
Uses crt;
var i,n,max; longint;
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do read(n); readln;
max:=a[1];
for i:=1 to n do if(max<a[i]) then max:=a[i];
write('So nguyen lon nhat la: ',max);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,ln,nn:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do
if a[i]>0 then t:=t+a[i];
ln:=a[1];
nn:=a[1];
for i:=1 to n do
begin
if ln<a[i] then ln:=a[i];
if nn>a[i] then nn:=a[i];
end;
writeln(t);
writeln(ln);
writeln(nn);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,ln,nn:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
ln:=a[1];
nn:=a[1];
for i:=1 to n do
begin
if ln<a[i] then ln:=a[i];
if nn>a[i] then nn:=a[i];
end;
writeln(ln);
writeln(nn);
readln;
end.
tìm cả min lẫn max mà bạn