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.
progam bai1;
var a: array[1..32000] of integer ;
i,n,dem1,dem2 : integer ;
begin
write('n='); readln(n);
writeln('Nhap gia tri cua cac phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
dem1:=0; dem2:=0;
for i:= 1 to n do
begin
if a[i]>0 then dem1:=dem1+1;
if a[i]>0 then dem1:=dem2+1;
end;
write('Cac so nguyen am trong day la:',dem1);
writeln;
write('Cac so nguyen am trong day la:',dem2);
readln;
end.
Program HOC24;
var n,d,i: integer;
B: array[1..100] of integer;
t: longint;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('B[',i,']='); readln(b[i]);
end;
d:=0; t:=0;
for i:=1 to n do
if b[i]>0 then
begin
d:=d+1;
t:=t+b[i];
end;
writeln('Tong cac so duong trong day so la: ',t);
write('Co ',d,' so duong trong day');
readln
end.
uses crt;
var b:array[1..100] of longint;
n,i,d,s:longint;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']: '); readln(b[i]);
if b[i]>0 then begin
inc(d);
inc(s,b[i]);
end;
end;
writeln('Tong cac so duong: ',s);
writeln('Co ',d,' so duong');
readln;
end.
program bt;
uses crt;
var i, s, sa, sd, sc, sl, da, dd, dc, dl : integer;
a : array[1..50] of integer;
begin
clrscr;
for i:=1 to 10 do begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
write('Day so vua nhap la: ');
for i:=1 to 10 do write(a[i],', ');
writeln;
s := 0; sa := 0; sd := 0; sc := 0; sl := 0; da := 0; dd := 0; dc := 0; dl := 0;
for i:=1 to 10 do begin
s := s + a[i];
if (a[i] > 0) then begin sd := sd + a[i]; dd := dd + 1 end;
if (a[i] < 0) then begin sa := sa + a[i]; da := da + 1 end;
if (a[i] mod 2 = 0) then begin sc := sc + a[i]; dc := dc + 1; end
else begin sl := sl + a[i]; dl := dl + 1 end;
end;
writeln('Tong cac phan tu trong mang la ',s);
writeln('Trung binh cong cac phan tu trong mang la ',s/10);
writeln('Tong cac so am la ',sa);
writeln('Tong cac so duong la ',sd);
writeln('Tong cac so chan la ',sc);
writeln('Tong cac so le la ',sl);
writeln('So cac so am la ', da);
writeln('So cac so duong la ', dd);
writeln('So cac so chan la ', dc);
writeln('So cac so le la ', dl);
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.
program im_14424;
uses crt;
var A: array[1..9999999] of interger;
S,P : integer;
i,n: byte;
begin
clrscr;
S:=0;
P:=0;
for i:=1 to n do
begin
write('Nhap vao phan tu thu: ',i,);
readln(A[i]);
S:=S+A[i]
P:=P*A[i]
end;
writeln(S);
write(P);
readln;
end.
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i]<0 then write(a[i]:4);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i]>0 then write(a[i]:4);
readln;
end.
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.
program dem_so_am_duong_0;
uses crt;
var B: array[1..100] of integer;
i, n, count_am, count_duong, count_0: integer;
begin
write('Nhap n: ');
readln(n);
for i :=1 to n do
begin
write('Nhap phan tu B[' , i, ']: ');
readln(B[i]);
end;
count_am :=0;
count_duong :=0;
count_0 :=0;
for i :=1 to n do
begin
if B[i] < 0 then
count_am := count_am + 1
else if B[i] > 0 then
count_duong := count_duong + 1
else
count_0 := count_0 + 1;
end;
write('So phan tu am trong mang: ', count_am);
write('So phan tu duong trong mang: ', count_duong);
write('So phan tu bang 0 trong mang: ', count_0);
readln;
end.