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.
bprogram min
uses crt
var A: array [1...250] of integer
tong :integer;
begin
tong:=0
writeln(‘nhap n:’); readln (n)
forr i:=1 to n do
begin
writeln (‘nhap phan tu thu ‘,i);
readln (A[i] );
end
for i:=1 to n do
begin
if (A[i] mod 3=0)
then tong:=tong +A[i];
end
writeln (Tong cac phan tu chia het cho 3)
readln ;
end
Program hotrotinhoc;
var i,n: integer;
a: array[1..100] of integer;
t: longint;
begin
write('Nhap so nguyen k : '); readln(k);
write('Nhap so nguyen n : '); readln(n);
t:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
if a[i] mod k=0 then t:=t+a[i];
end;
write('Tong cac phan tu cua mang la boi cua so nguyen duong k la :',t);
readln
end.
uses crt;
var a:array[1..50]of integer;
i,n,t,t1:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=50);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]<=100;
end;
t:=0;
t1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then t:=t+a[i]
else t1:=t1+a[i];
end;
writeln('Tong cac so chan la: ',t);
writeln('Tong cac so le la: ',t1);
readln;
end.
Mình chỉ viết chương trình chính thôi, còn chương trình con bạn tự viết nhé
uses crt;
var a:array[1..100]of integer;
i,n,t,t1,t2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
edn;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(t);
readln;
end.
Câu 1:
uses crt;
var a:array[1..10]of integer;
i,n,t:integer;
begin
clrscr;
write('n='); readln(n);
if (n>0) and (n<=10) then
begin
t:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
t:=t+a[i];
end;
writeln('tong cua day so la: ',t);
end
else writeln('vui long nhap lai');
readln;
end.
Câu 2:
uses crt;
var b:array[1..20]of integer;
i,n:integer;
begin
clrscr;
write('n='); readln(n);
if (n>0) and (n<=20) then
begin
for i:=1 to n do
begin
write('b[',i,']='); readln(b[i]);
end;
for i:=1 to n do
write(b[i]:4);
end
else writeln('vui long nhap lai');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int B[100],i,n,t=0,s=1;
int main()
{
cin>>n;
for (int i=1; i<=n; i++) cin>>B[i];
for (int i=1; i<=n; i++)
{
if (i%2==0) s*=A[i];
else t+=A[i];
}
cout<<t<<" "<<s;
}
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.
program hotrotinhoc;
var i,n: byte;
t: longint;
a: array[1..150] of integer;
begin
write('n='); readln(n);
t:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
if (a[i] mod 3=0) and (a[i] mod 5=0) then t:=t+a[i];
end;
writeln('Cac phan tu le trong mang : ');
for i:=1 to n do if a[i] mod 2=1 then write(a[i],' ');
writeln;
write('Tong phan tu chia het cho 3 va 5 la :',t);
readln
end.
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;
{-------------------------xu-ly------------------------}
writeln('cac so le trong day la: ');
for i:=1 to n do
if a[i] mod 2=1 then write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if (a[i] mod 3=0) and (a[i] mod 5=0) then t:=t+a[i];
writeln('tong cac phan tu chia het cho 3 va chia het cho 5 la: ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long x,i,n,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
t=t+x;
}
cout<<t;
return 0;
}