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 n, i, j, dem: longint; {Bạn có thể thay longint thành integer nha}
A:array[1..1000] of longint;
begin
clrscr;
Write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': ');
readln(A[i]);
end;
Write('Cac so nguyen to co trong mang la: ');
for i:=1 to n do
begin
dem:=0;
for j:=2 to A[i]/2 do
if A[i] mod j=0 then dem:=dem+1;
if dem=0 then write(A[i],'; ');
end;
end.
uses crt;
var a:array[1..100]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
t:=t+a[i];
writeln(t);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
readln;
end.
Var a:array[1..1000] of integer;
i,m,tam:integer;
Begin
Write('m = ');readln(m);
For i:=1 to m do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to m do
If a[i] < a[i+1] then
Begin
tam:=a[i];
a[i]:=a[i+1];
a[i+1]:=tam;
End;
Write('Mang sau khi sap xep: ');
For i:=1 to m do
Write(a[i]:8);
Readln;
End.
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.
uses crt;
var n,i,max : integer;
a : array[1..100] of integer;
begin
clrscr;
write('Nhap so n :'); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' la : '); readln(a[i]);
end;
max:=a[1];
for i:=2 to n do if max<a[i] then max:=a[i];
write('So *** nhat trong mang la :', max);
min:=a[1];
for i:=2 to n do if min>a[i] then min:=a[i];
write('So nho nhat trong mang la :', min);
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 min,max,i,n: integer;
a: array[1..1000] of integer;
begin
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:=2 to n do
begin
if a[i]> max then max:=a[i];
if a[i]<min then min:=a[i];
end;
writeln('Gia tri lon nhat la: ',max);
write('Gia tri nho nhat la: ',min);
readln
end.
Uses crt;
var n,i,x,u: integer;
begin clrscr;
readln(n);
for i:=1 to n do begin
readln(x);
u:=u+x;
end;
writeln(u);
readln;
end.
program TongCacSoNguyen;
var
N, i, soNguyen, tong: integer;
begin
// Nhập số lượng N
write('Nhap so luong N: ');
readln(N);
// Khởi tạo tổng
tong := 0;
// Nhập và tính tổng các số nguyên
for i := 1 to N do
begin
write('Nhap so nguyen thu ', i, ': ');
readln(soNguyen);
tong := tong + soNguyen;
end;
// In ra màn hình tổng
writeln('Tong cua cac so nguyen la: ', tong);
readln;
end.
Bài 1:
uses crt;
var n,i,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
i:=1;
while i<=n do
begin
s:=s+i;
inc(i);
end;
writeln('Tong cac so trong khoang tu 1 den ',n,' la: ',s);
readln;
end.
Bài 2:
uses crt;
var n,i,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
i:=1;
while i<=n do
begin
s:=s+i;
i:=i+2;
end;
writeln('Tong cac so le trong khoang tu 1 den ',n,' la: ',s);
readln;
end.
Bài 1:
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.
Bài 2:
uses crt;
var n,i,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
for i:=1 to n do
s:=s+i;
writeln('Tong cua ',n,' so tu nhien dau tien la: ',s);
readln;
end.
Bài 3:
uses crt;
var n,t:integer;
begin
clrscr;
n:=0; t:=0;
while t<=1000 do
begin
inc(n);
t:=t+n;
end;
writeln('Tong cua n so tu nhieu dau tien sao cho tong nho nhat lon hon 1000 la: ',t);
writeln('So lan n nang len la: ',n);
readln;
end.
Bài 4:
uses crt;
var a,b:integer;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
if a<b then writeln(a,' ',b);
if a=b then writeln('hai so bang nhau');
if b<a then writeln(b,' ',a);
readln;
end.
Bài 5:
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('Gia tri nho nhat la: ',min);
readln;
end.