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..20]of integer;
i,n,t,dem:integer;
begin
clrscr;
for i:=1 to 20 do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]>0;
end;
t:=0;
for i:=1 to 20 do
t:=t+a[i];
writeln('Tong cac so trong mang la: ',t);
dem:=0;
for i:=1 to 20 do
if a[i] mod 2=0 then inc(dem);
writeln('Trong mang co ',dem,' so chan');
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,min,dem: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];
dem:=0;
for i:=1 to n do
if min=a[i] then inc(dem);
writeln('So phan tu co gia tri nho nhat la: ',dem);
readln;
end.
Câu 1:
uses crt;
var a:array[1..500]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
if (a[i]<0) and (a[i] mod 7=0) then t:=t+a[i];
writeln('Tong cac so am chia het cho 7 la: ',t);
readln;
end.
Câu 2:
uses crt;
var c,a:array[1..10]of integer;
i,kt,j,dem:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('C[',i,']='); readln(c[i]);
end;
dem:=0;
for i:=1 to 10 do
if c[i]>1 then
begin
kt:=0;
for j:=2 to c[i]-1 do
if c[i] mod j=0 then kt:=1;
if kt=0 then
begin
inc(dem);
a[dem]:=c[i];
end;
end;
if dem=0 then writeln('Trong day khong co so nguyen to')
else begin
writeln('Cac so nguyen to trong day la: ');
for i:=1 to dem do
write(a[i]:4);
end;
readln;
end.
Câu 3:
uses crt;
var d:array[1..200]of integer;
i,k,dem:integer;
begin
clrscr;
write('Nhap k='); readln(k);
for i:=1 to k do
begin
write('D[',i,']='); readln(d[i]);
end;
dem:=0;
for i:=1 to k do
if (a[i] mod 2=0) and (a[i]>=10) then inc(dem);
writeln('So phan tu chan co 2 chu so la: ',dem);
readln;
end.
1.
Program Tim_Max;
Var A:Array[1..255] of Integer;
i, n, Max: Integer;
Begin
Write('Nhap n: '); Readln(n);
For i := 1 to n do
Begin
Write('Nhap phan tu A[',i,'] = '); Readln(A[i]);
End;
Max := A[1];
For i := 2 to n do if A[i]>Max then Max := A[i];
Write('Phan tu lon nhat la :',Max);
Readln
End.
2.
Uses Crt;
Type Mang = ARRAY[1..50] Of Integer;
Var A:Mang;
N,i,j,Tam:Integer;
Begin
{Nhập mảng}
Write('Nhap N='); Readln(N);
For i:=1 To N Do
Begin
Write('A[',i,']='); Readln(A[i]);
End;
{Sắp xếp}
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;
{In kết quả ra màn hình}
Writeln('Ket qua sau khi sap xep:');
For i:=1 To N Do Write(A[i]:5);
Readln;
End.
3.
Uses Crt;
Type Mang = ARRAY[1..50] Of Integer;
Var A:Mang;
N,i,x:Integer;
Function TimKiem(x, N: Integer; A:Mang):Integer;
Var i:Integer;
Begin
I:=1;
While (I <= N) and (X<>A[I]) do I:=I+1; {{{{tại sao lại phải làm như bước này, tại sao lại lấy i đi so sánh với N}}}}
If I <= N Then Timkiem:=I Else Timkiem:=0;
End;
Begin
{Nhập mảng}
Write(‘Nhap N=’); Readln(N);
For i:=1 To N Do
Begin
Write(‘A[‘,i,’]=’); Readln(A[i]);
End;
Write(‘Nhap X=’); Readln(x);
{Kết quả tìm kiếm}
If TimKiem(X,N,A)<>0 Then
Writeln(‘Vi tri cua X trong mang la:’, TimKiem(X,N,A))
Else Writeln(‘X khong co trong mang.’);
Readln;
End.
câu 1 tham khảo cái này nhé
Uses Crt;
Type Mang = ARRAY[1..50] Of Integer;
Var A:Mang;
N,i,Max:Integer;
Begin
Write('Nhap N='); Readln(N);
For i:=1 To N Do
Begin
Write('A[',i,']='); Readln(A[i]);
End;
Max:=A[1];
For i:=2 To N Do
If Max<A[i] Then Max:=A[i];
Writeln('Phan tu lon nhat cua mang:', Max);
Readln;
End.
Var a:array[1..20] of integer;
i,n,d:integer;
Begin
For i:=1 to 20 do
Begin
Write('Nhap phan tu thu ',i);readln(a[i]);
if a[i] = 3 then d:=d+1;
End;
Write('Co ',d,' chu so 3');
Readln
End.
uses crt;
var a:array[1..1000]of integer;
i,n,dem,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=1000);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until abs(a[i])<=1000;
end;
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i]=0 then inc(dem);
writeln('So phan tu bang 0 la: ',dem);
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln('Tong cac phan tu chan la: ',t);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,kt,dem,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then
begin
kt:=1;
break;
end;
if kt=0 then inc(dem);
end;
writeln('So phan tu la so nguyen to la: ',dem);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (1<=n) and (n<=1000);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Mang ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i] mod 3=0 then inc(dem);
writeln('So phan tu chia het cho 3 la: ',dem);
readln;
end.