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.
Bài 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] mod 2<>0 then write(a[i]:4);
readln;
end.
Bài 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] mod 2=0 then write(a[i]:4);
readln;
end.
Câu 1:
uses crt;
var a:array[1..200]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] mod 2=0 then t:=t+a[i];
writeln(t);
readln;
end.
Câu 1:
uses crt;
var a:array[1..100]of real;
i,n:integer;
t:real;
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] mod 2=0 then t:=t+a[i];
writeln(t:4:2);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
t:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=1;
for i:=1 to n do
t:=t*a[i];
writeln(t:4:2);
readln;
end.
Uses crt;
var max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+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('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
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.
Uses crt;
var max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+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('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
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..1000] of integer;
i,n:integer;
sc,sl:longint;
Begin
Write('Nhap so luong so cua day ');readln(n);
For i:=1 to n do
Begin
Write(a,'[',i,'] = ');readln(a[i]);
End;
Write('Tong cac so chan la ');
For i:=1 to n do
If a[i] mod 2 = 0 then sc:=sc+a[i];
Writeln(sc);
Write('Tong cac so le la ');
For i:=1 to n do
If a[i] mod 2 <> 0 then sl:=sl+a[i];
Write(sl);
Readln
End.
a) var a:array[1..1000] of integer;
i,k:integer;
p:longint;
begin
write('k = ');readln(k);
p:=1;
for i:=1 to k do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
if a[i]<30 then p:=p*a[i];
end;
write('Tich la ',p);
readln
end.
b)
var a:array[1..1000] of integer;
i,k:integer;
s:longint;
begin
write('k = ');readln(k);
for i:=1 to k do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
if a[i]<100 then s:=s+a[i];
end;
write('Tong la ',s);
readln
end.
program tongduong;
uses crt;
var a:array[1..100] of integer;n,i,s:integer;
begin
clrscr;
s:=0;
writeln('nhap do dai cua day');readln(n);
for i:=1 to n do begin writeln('a[',i,']= ');readln(a[i]); end;
for i:=1 to n do if a[i] mod 2 = 0 then s:=s+a[i];
write(' Tong cac so duong trong day la',s);
readln
end.
Bạn the pie mới có lệnh nhập độ dài của dãy còn chưa có lệnh nhập các phần tử trong dãy nhé :)))
uses crt;
var a:array[1..249]of integer;
i,n,t,dem:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<250);