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 n,i,x,dem,t;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%3==0)
{
dem++;
t+=x;
}
}
cout<<dem<<" "<<t;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a,b,k;
cin>>a>>b>>k;
for (int i=a; i<=b; i++)
if (i%k==0) cout<<i<<" ";
return 0;
}
Câu 1:
program mangsonguyen;
var
a: array[1..100] of integer;
i, n: integer;
begin
writeln('Nhap so phan tu trong mang: ');
readln(n);
writeln('Nhap cac phan tu cua mang: ');
for i := 1 to n do
readln(a[i]);
writeln('Mang vua nhap la:');
for i := 1 to n do
write(a[i], ' ');
end.
Câu 2:
program trungbinhcong;
var
a: array[1..100] of integer;
i, n, k, sum: integer;
avg: real;
begin
writeln('Nhap so phan tu trong mang: ');
readln(n);
writeln('Nhap cac phan tu cua mang: ');
for i := 1 to n do
readln(a[i]);
writeln('Nhap so k: ');
readln(k);
sum := 0;
for i := 1 to n do
begin
if a[i] <= k then
sum := sum + a[i];
end;
if sum > 0 then
begin
avg := sum / n;
writeln('Trung binh cong cac phan tu co gia tri <= ', k, ' la: ', avg:0:2);
end
else
begin
writeln('Khong co phan tu nao co gia tri <= ', k);
end;
end.
Câu 3:
program DemSoNguyenTo;
var
a: array [1..100] of integer;
i, j, n, count: integer;
laSoNguyenTo: boolean;
begin
write('Nhap so phan tu cua mang: ');
readln(n);
write('Nhap cac phan tu cua mang: ');
for i := 1 to n do
readln(a[i]);
count := 0;
writeln('Cac so nguyen to trong mang la: ');
for i := 1 to n do
begin
laSoNguyenTo := true;
for j := 2 to (a[i] div 2) do
begin
if (a[i] mod j = 0) then
begin
laSoNguyenTo := false;
break;
end;
end;
if laSoNguyenTo and (a[i] > 1) then
begin
writeln(a[i]);
count := count + 1;
end;
end;
writeln('Tong so cac so nguyen to la: ', count);
readln;
end.
Program HOC24;
var m,n,i: integer;
t1,t2: longint;
begin
write('Nhap m;n: '); readln(m,n);
t1:=1; t2:=1;
for i:=1 to n do t1:=t1*i;
for i:=m to n do t2:=t2*i;
writeln('T1=',t1);
write('T2=',t2);
readln
end.
uses crt;
var a:array[1..100]of integer;
i,n,k,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
t:=0;
for i:=1 to n do
if a[i] mod k=0 then t:=t+a[i];
writeln(t);
readln;
end.
Python:
n=int(input("Nhap so nguyen duong n:"))
dem=0
for i in range(1,n+1):
if i%4==0:
dem=dem+1
print(dem)
Bài 1:
Program HOC24;
var i,n,d : byte;
t: integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
for i:=1 to n do if (a[i] mod 3=0) and (a[i] mod 5=0) then
begin
d:=d+1;
t:=t+a[i];
end;
writeln('Co ',d,' phan tu la boi cua 3 va 5');
write('Tong la: ',t);
readln
end.
Bài 2:
Program HOC24;
var i,n,k : byte;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
write('Nhap k: '); readln(k);
for i:=1 to n do if a[i]=k then d:=d+1;
writeln('Co ',d,' phan tu bang ',k);
Write('Cac chi so do la: ');
for i:=1 to n do if a[i]=k then write(i,' ');
readln
end.
uses crt;
var a:array[1..10]of integer;
i,n,dem:integer;
begin
clrscr;
for i:=1 to 10 do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]>0;
end;
writeln('Day so vua nhap la: ');
for i:=1 to 10 do
write(a[i]:4);
dem:=0;
for i:=1 to n do
if a[i] mod 2=0 then inc(dem);
writeln;
writeln('So luong so chan la: ',dem);
readln;
end.
Program HOC24;
var a: array[1..100] of integer;
d,i,n: integer;
begin
write('Nhap so phan tu cua day : '); readln(n);
d:=0;
for i:=1 to n do
begin
write('Nhap so thu ',i,':'); readln(a[i]);
if a[i] mod 3=0 then d:=d+1;
end;
writeln('Co ',d,' so chia het cho 3');
write('Cac so chia het cho 3 la : ');
for i:=1 to n do write(a[i],' ');
readln
end.