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.
#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++)
if (a[i]%3==0) t+=a[i];
cout<<t;
return 0;
}
type mang=array[1..10]of integer;
function demsochiahet(a:mang):integer;
var dem,i,n:integer;
begin
dem:=0;
for i:=1 to n do
if a[i] mod 7=0 then inc(dem);
demsochiahet:=dem;
end;
const fi='dl.pas';
fo='qk.pas';
var f1,f2:text;
i,n,dem,t,dem1,dem2,kt,j:integer;
a:array[1..100]of integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
dem:=0;
for i:=1 to n do
if (a[i] mod 2<>0) and (a[i] mod 7=0) then inc(dem);
t:=0;
for i:=1 to n do
if (10<=a[i]) and (a[i]<=30) then t:=t+a[i];
dem1:=0;
for i:=1 to n do
if (a[i]<0) and (a[i] mod 2<>0) then inc(dem1);
dem2:=0;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to a[i]-1 do
if a[i] mod j=0 then kt:=1;
if kt=0 then inc(dem2);
end;
writeln(f2,'So phan tu le chia het cho 7 la: ',dem);
writeln(f2,'Tong cac phan tu thuoc [10,30] la: ',t);
writeln(f2,'So cac phan tu am le la: ',dem1);
writeln(f2,'So phan tu la so nguyen to la: ',dem2);
close(f1);
close(f2);
end.
Khi nãy gửi nhầm 2 cái nha
program Baitap1;
uses crt;
var Min ,n, i:integer;
A: array [1..1000] of integer;
begin
clrscr;
write('Nhap N ');readln(n);
for i:=1 to n do begin
write('A[',i,']=');readln(A[i]);
end;
Min:=A[1];
for i:=1 to n do if Min>A[i] then Min:=A[i];
write('So Nho Nhat Trong Mang La ',Min);
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.
uses crt;
var a:array[1..100]of integer;
i,n,dem:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (1<=n) and (n<=1000);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Mang ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i] mod 3=0 then inc(dem);
writeln('So phan tu chia het cho 3 la: ',dem);
readln;
end.
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
uses crt;
var a:array[1..100]of integer;
i,n,t,dem:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{----------------------------------cau-a------------------------------}
for i:=1 to n do
write(a[i]:4);
{----------------------------cau-b--------------------------}
writeln;
dem:=0;
for i:=1 to n do
if a[i] mod 2<>0 then inc(dem);
writeln('so phan tu le la: ',dem);
{-----------------------cau-c-----------------------}
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln('tong cac phan tu chia het cho 3 la: ',t);
readln;
end.