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,b,ucln,bcnn,i:integer;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
ucln:=1;
if a<b then begin
for i:=1 to a do
if (a mod i=0) and (b mod i=0) then begin
if ucln<i then ucln:=i;
end;
end else begin
for i:=1 to b do
if (a mod i=0) and (b mod i=0) then
begin
if ucln<i then ucln:=i;
end;
end;
bcnn:=a*b;
for i:=a*b-1 downto 1 do
if (i mod a=0) and (i mod b=0) then
begin
if bcnn>i then bcnn:=i;
end;
writeln('Uoc chung lon nhat la: ',ucln);
writeln('Boi chung nho nhat la: ',bcnn);
readln;
end.
program UocChung;
var
a, b, i: integer;
uocchung: array[1..100] of integer;
n: integer;
begin
write('Nhap a=');
readln(a);
write('Nhap b=');
readln(b);
n := 0;
for i := 1 to 100 do
if (a mod i = 0) and (b mod i = 0) then
begin
uocchung[n] := i;
n := n + 1;
end;
write('Uoc chung cua ', a, ' va ', b, ' la: ');
for i := 0 to n-1 do
write(uocChung[i], ' ');
readln;
end.
program b1;
uses crt;
var a:array[1..100] of integer; i,n,max,min:integer;
begin
clrscr;
write('Nhap vao so nguyen n:');
readln(n);
for i:=1 to n do
readln(a[i]);
min:=a[1];
max:=a[1];
for i:=2 to n do
begin
if(a[i]<min) then min:=a[i];
if(a[i]>max) then max:=a[i];
end;
writeln(' gia tri lon nhat = ',max);
writeln(' gia tri nho nhat = ',min);
readln;
end.
Tham khảo!
Đề 1:
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.
Đề 2:
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.
1. uses crt;
var a,vt:array[1..100]of integer;
n,i,t,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]>=0;
end;
t:=0;
for i:=1 to n do
begin
if t<100 then
begin
t:=t+a[i];
dem:=dem+1;
vt[dem]:=i;
end;
end;
writeln(vt[dem]);
readln;
end.
Câu 2:
uses crt;
var a:array[1..30]of integer;
i,n,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
kt:=0;
for i:=1 to n-1 do
if a[i]>=a[j] then kt:=1;
if kt=0 then writeln('Day la day so khong giam')
else writeln('Day khong la day so khong giam');
readln;
end.
Program HOC24;
var a: array[1..32000] of integer;
i,max,min,n: integer;
begin
write('Nhap so phan tu 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 a[i]>max then max:=a[i];
if a[i]<min then min:=a[i];
end;
writeln('So nho nhat la :',max);
write('So lon nhat 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('So lon nhat la: ',max);
writeln('So nho nhat la: ',min);
readln;
end.
tìm ước chung lớn nhất của a và b rồi so sánh với c nha
uses crt;
var a,b,c,min,ucln,bcnn:longint;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
write('c='); readln(c);
min:=a;
if min>b then min:=b;
if min>c then min:=c;
ucln:=1;
for i:=1 to min do
if (a mod i=0) and (b mod i=0) and (c mod i=0) then
begin
if ucln<i then ucln:=i;
end;
writeln('uoc chung lon nhat=',ucln);
bcnn:=a*b*c;
for i:=a*b*c downto 1 do
if (i mod a=0) and (i mod b=0) and (i mod c=0) then
begin
if bcnn>i then bcnn:=i;
end;
writeln('Boi chung nho nhat=',bcnn);
readln;
end.