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.
program tinh_tong_va_dem_so_x;
const
MAX = 100;
var
a: array[1..MAX] of integer;
n, tong, x, dem, i: integer;
begin
write('Nhap so phan tu cua mang: ');
readln(n);
for i := 1 to n do
begin
write('Nhap phan tu thu ', i, ': ');
readln(a[i]);
end;
tong := 0;
for i := 1 to n do
begin
tong := tong + a[i];
end;
writeln('Tong cac phan tu trong mang la: ', tong);
write('Nhap gia tri x: ');
readln(x);
dem := 0;
for i := 1 to n do
begin
if a[i] = x then
begin
dem := dem + 1;
end;
writeln('So lan xuat hien cua ', x, ' trong mang la: ', dem);
readln;
end.
Câu 1:
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.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,x,dem,kt:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap x='); readln(x);
kt:=0;
dem:=0;
for i:=1 to n do
if a[i]=x then
begin
kt:=1;
write(i:4);
inc(dem);
end;
if kt=0 then writeln('Khong co ',x,' trong day');
writeln(x,' xuat hien ',dem,' lan trong day');
readln;
end.
Var a:array[1..200] of integer;
i,n,dem:integer;
Begin
Write('Nhap so luong phan tu n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
dem:=0;
For i:=1 to n do
If a[i]>5 then dem:=dem+1;
Write('So phan tu lon hon 5 la ',dem);
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..100]of integer;
i,n,x,dem:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap x='); readln(x);
dem:=0;
for i:=1 to n do
if a[i]=x then inc(dem);
writeln(dem);
readln;
end.
Var a:array[1..200] of integer;
i,n,d1,d2,s:integer;
Begin
Write('Nhap so luong phan tu n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do
Begin
If a[i] mod 2 = 0 then d1:=d1+1;
If (a[i] > 0) and (a[i] < 51) then d2:=d2+1;
End;
Writeln('Co ',d1,' so chan');
Write('Co ',d2,' so tu 1 den 50');
Readln;
End.
uses crt;
var a:array[1..100]of integer;
i,n,k,h,dem,t,dem1,dem2,t1,t2:integer;
begin
clrscr;
for i:=1 to 100 do
begin
write('A[',i,']='); readln(a[i]);
end;
n:=100;
write('Nhap k='); readln(k);
for i:=1 to n do
if a[i]=k then write(i:4);
writeln;
write('Nhap h='); readln(h);
dem:=0;
for i:=1 to n do
if a[i]=h then inc(dem);
writeln(h,' xuat hien ',dem,' lan trong mang');
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cac phan tu cua day la: ',t);
dem1:=0;
t1:=0;
dem2:=0;
t2:=0;
for i:=1 to n do
begin
if a[i]>0 then
begin
inc(dem1);
t1:=t1+a[i];
end;
if a[i]<0 then
begin
inc(dem2);
t2:=t2+a[i];
end;
end;
writeln('Co ',dem1,' so duong');
writeln('Tong cac so duong la: ',t1);
writeln('Co ',dem2,' so am');
writeln('Tong cac so am la: ',t2);
readln;
end.
program im_14424;
uses crt;
var A: array[1..1000000] of longint;
S: longint;
i: integer;
begin
clrscr;
write('Nhap vao n: ');
readln(n);
S:=0;
for i:=1 to n do
begin
write('Nhap phan tu thu`,i,':');
readln(A[i]);
S:=S+i;
end;
readln
end.