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,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.
Bai 2:
uses crt;
var a:array[1..100]of integer;
i,n,t,nn:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
nn:=a[1];
for i:=1 to n do
if nn>a[i] then nn:=a[i];
write(nn);
readln;
end.
uses crt;
const fi='ketqua.out';
var f1:text;
a:array[1..100]of integer;
i,n,min:integer;
begin
clrscr;
assign(f1,fi); rewrite(f1);
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(f1,min);
close(f1);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
unsigned long long a[50],x,n,uc,i;
//chuongtrinhcon
unsigned long long ucln(long long a,long long b)
{
if (b==0) return(a);
else return(ucln(b,a%b));
}
//chuongtrinhchinh
int main()
{
freopen("ucln.inp","r",stdin);
freopen("ucln.out","w",stdout);
cin>>n;
cin>>a[1]>>a[2];
uc=ucln(a[1],a[2]);
for (i=3; i<=n; i++)
{
cin>>x;
uc=ucln(uc,x);
}
cout<<uc;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,tc,tl,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
tc:=0;
tl:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then tc:=tc+a[i]
else tl:=tl+a[i];
end;
writeln('Tong cac so chan la: ',tc);
writeln('Tong cac so le la: ',tl);
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day so la: ',t);
readln;
end.
program bai_2;
uses crt;
var a:array[1..100]of byte;
n,i,j,tam,vt,vt2,x,x2,k,ch:byte;
procedure yc1;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do write(a[i]:3);
end;
procedure yc2;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('mang a:');for i:=1 to n do write(a[i]:3);
end;
procedure yc3;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
write('nhap so x:');readln(x);
for i:=n downto 1 do
if a[i]=x then vt:=i;if a[i]=x then writeln('vi tri cua ',x,' trong mang a la:',vt);writeln;
if a[i]<>x then writeln('khong tim thay ',x,' trong day so tren');writeln;
end;
procedure yc4;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
write('nhap so x2:');readln(x2);
for i:=n downto 1 do
if a[i]=x2 then vt2:=i;if x>0 then
begin
for i:=vt2 to n-1 do a[i]:=a[i+1];
for i:=1 to n-1 do write(a[i]:3);
end
else if a[i]<>x2 then write('khong tim thay ',x2,' trong day so tren');
end;
procedure yc5;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
write('nhap vi tri:');readln(vt);
for i:=1 to n do
if (vt=i) then writeln('phan tu o vi tri ',vt,' la:',a[vt]:3);
for i:=vt to n-1 do a[i]:=a[i+1];
for i:=n downto vt+1 do a[i]:=a[i-1];
write('nhap so can sua:');readln(a[vt]);
writeln('day so sau khi sua la:');
for i:=1 to n do write(a[i]:3); writeln;
end;
procedure yc6;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
write('nhap vi tri can chen k:');readln(k);
for i:=n+1 downto k+1 do a[i]:=a[i-1];
write('nhap so can chen vao day:');readln(a[k]);
writeln('day so sau khi chen ',a[k],' vao day la:');
for i:=1 to n+1 do write(a[i]:3);writeln;
end;
procedure yc7;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do
write(a[i]:3);
writeln;
end;
BEGIN
clrscr;
while ch<8 do
begin
clrscr;
writeln('CHON MOT TRONG CAC SO SAU:');
writeln('1.NHAP DAY SO:');
writeln('2.SAP XEP DAY SO:');
writeln('3.TIM MOT SO:');
writeln('4.XOA MOT SO:');
writeln('5.SUA MOT SO:');
writeln('6.CHEN MOT SO:');
writeln('7.IN DAY SO:');
writeln('8.THOAT KHOI CHUONG TRINH:');
write('nhap so co yeu cau ban muon lam:');readln(ch);
if ch<8 then
begin write('nhap so n:');readln(n); end;
case ch of
1:yc1;
2:yc2;
3:yc3;
4:yc4;
5:yc5;
6:yc6;
7:yc7;
end;
readln;
end;
readln;
end.
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.