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: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
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day la: ',t);
for i:=1 to n do
if a[i]>50 then write(a[i]:4);
writeln;
for i:=1 to n do
if a[i]<30 then write(a[i]:4);
readln;
end.
program TongSoChiaHetCho5;
var
n, i, x, tong: integer;
begin
write('Nhap so phan tu n: ');
readln(n);
tong := 0;
for i := 1 to n do
begin
write('Nhap phan tu thu ', i, ': ');
readln(x);
if (x > 0) and (x mod 5 = 0) then
tong := tong + x;
end;
writeln('Tong cac so lon hon 0 va chia het cho 5 la: ', tong);
readln;
end.
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) and (a[i] mod 5=0) then write(a[i]:4);
readln;
end.
Var a:array[1..1000] of integer;
i,x:integer;
s:longint;
Begin
Write('x = ');readln(x);
For i:=1 to x do
Begin
Write('Nhap phan tu thu ',i);readln(a[i]);
if a[i] mod 2 = 0 then s:=s+a[i];
End;
writeln('Tong cac so chia het cho 2 la ',s);
write('Cac so vua nhap la ');
for i:=1 to x do write(a[i]:5);
Readln
End.
#include <bits/stdc++.h>
using namespace std;
long long a[100],n,i,s,t,ln,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
s=1;
t=0;
ln=a[1];
nn=a[1];
for (i=1; i<=n; i++)
{
s=s*a[i];
t+=a[i];
ln=max(ln,a[i]);
nn=min(nn,a[i]);
}
cout<<s<<endl;
cout<<t<<endl;
cout<<ln<<endl;
cout<<nn;
return 0;
}
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.
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.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,t;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++)
if (i%3==0) t+=i;
cout<<t<<endl;
for (i=1; i<=n; i++)
if (a[i]<0) cout<<a[i]<<" ";
return 0;
}
var a:[array] of integer;
i,n,max,min,s:integer;
begin
write('Nhap so luong so 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];
s:=0;
for i:=1 to n do
begin
if a[i] > max then max:=a[i];
if a[i] < min then min:=a[i];
s:=s+a[i];
end;
writeln('So lon nhat la ',max);
writeln('So nho nhat la ',min);
writeln('Tong cac phan tu trong day la ',s);
writeln('Cac so chia het cho 2 la: ');
for i:=1 to n do
if a[i] mod 2 = 0 then write(a[i],' ');
readln;
end.
uses crt;
var a:array[1..100] of integer;
begin
write('nhap do dai day');readln(n);
for i:=1 to n do begin writeln('a[',i,']');readln(a[i]);
if (a[i] >30) and (a[i] mod 5 = 0) then write(a[i],' ');end;
readln;
end.