viết chương trình tính tổng các số lẻ từ 25-50 chia hết cho 5
( giúp mình với mình cần gấp lắm ạ)
Viết chương trình đếm xem có bao nhiêu số chia hết cho 3 và cho 4 trong khoảng 0 -->10000 , tính tổng của các số này .
Mình cần gấp ạ :(( mn giúp mình với , cảm ơn ạ
#include <bits/stdc++.h>
using namespace std;
long long i,t,dem;
int main()
{
dem=0;
t=0;
for (i=0; i<=10000; i++)
if (i%12==0)
{
dem++;
t=t+i;
}
cout<<dem<<" "<<t;
return 0;
}
Đề: Viết chương trình nhập từ bàn phím số nguyên dương n và dãy số từ \(a_1\) , \(a_2\) , ... , \(a_n\) . In ra màn hình tổng các số lẻ có trong dãy số.
P/S: Mọi người giúp mình với, mình đang cần gắp lắm ạ!
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
if a[i] mod 2<>0 then t:=t+a[i];
writeln(t);
readln;
end.
MÌNH CẦN GẤP Ạ, MAI THI RỒI :(( 1. Viết chương trình tính tổng và tích các số chia hết cho 3 trong dãy số N. 2. Viết chương trình đếm xem trong dãy số N có bao nhiêu số chẵn và tính tổng các số chẵn đó. 3. Viết chương trình đếm có bao nhiêu số chẵn hoặc lẻ trong dãy số N rồi tính tổng và tích của các số chẵn và lẽ đó. Mong mọi người giúp mình :((
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n,t,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
s:=1;
dem:=0;
for i:=1 to n do
if a[i] mod 3=0 then
begin
inc(dem);
t:=t+a[i];
s:=s*a[i];
end;
if dem=0 then writeln('Khong co so chia het cho 3 trong day')
else begin
writeln('Tong cac so chia het cho 3 la: ',t);
writeln('Tich cac so chia het cho 3 la: ',s);
end;
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
inc(dem);
t:=t+a[i];
end;
writeln('So so chan la: ',dem);
writeln('Tong cac so chan la: ',t);
readln;
end.
Câu 3:
uses crt;
var a:array[1..100]of integer;
i,n,dem1,dem2,t1,t2,s1,s2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem1:=0;
dem2:=0;
t1:=0;
t2:=0;
s1:=1;
s2:=1;
for i:=1 to n do
begin
if a[i] mod 2=0 then
begin
inc(dem1);
t1:=t1+a[i];
s1:=s1*a[i];
end
else begin
inc(dem2);
t2:=t2+a[i];
s2:=s2*a[i];
end;
end;
if dem1=0 then writeln('Khong co so chan trong day')
else begin
writeln('So so chan la: ',dem1);
writeln('Tong cac so chan la: ',t1);
writeln('Tich cac so chan la: ',s1);
end;
if dem2=0 then writeln('Khong co so le trong day')
else begin
writeln('So so le la: ',dem2);
writeln('Tong cac so le la: ',t2);
writeln('Tich cac so le la: ',s2);
end;
readln;
end.
viết chương trình con tính tổng các số chia hết cho 3 từ 1 đến n-1
giúp tui với ạ tui đang cần gấp á
n = int(input("Nhap vao mot so n: "))
tong = 0
for i in range(1, n):
if i % 3 == 0:
tong += i
print("Tong cac so chia het cho 3 tu 1 den", n-1, "la:", tong)
Câu 1: viết chương trình nhập vào N số tự nhiên đầu tiên,đếm xem có bao nhiêu số là số chẵn Câu 2: Viết chương trình nhập vào N số tự nhiên tính tổng các số chia hết cho 3 Em cần gấp lắm ạ:(
1:
#include <bits/stdc++.h>
using namespace std;
long long dem,i,n,x;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) dem++;
}
cout<<dem;
return 0;
}
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%3==0) t+=x;
}
cout<<t;
return 0;
}
Viết chương trình tính tổng các số chẵn trong dãy số nguyên A1, A2, ..., An. Biết rằng n, A1, A2, ..., An là các số nguyên nhập từ bàn phím (n>0)?
Các bạn giúp mình nha ,mình cần gấp lắm
program Tinhtong;
uses crt;
var a:array[1..100] of integer;
sum,n:integer;
begin clrscr;
write('Nhap n = '); readln(n);
for i:=1 to n do
begin
write('a[',i,'] = '); readln(a[i]);
end;
sum:=0;
for i:=1 to n do
if (a[i] mod 2 = 0) then sum:=sum+a[i];
write('Tong cac so chan = ',sum);
readln;
end.
1/viết chương trình nhập dãy số gồm 10 số nguyên dương.In ra màn hình số bé nhất (Min)
2/viết chương trình nhập dãy số gồm n số nguyên.
a. Tính tổng các phần tử của dãy.
b. In ra màn hình các phần tử là số chẵn hoặc lẻ.
[Giúp mình với mình đang cần gấp mai là mình thì rồi. Cảm ơn mn trước ạ]
1:
#include <bits/stdc++.h>
using namespace std;
long long n=10, a[10],i,nn;
int main()
{
for (i=1; i<=n; i++) cin>>a[i];
nn=a[1];
for (i=2; i<=n; i++) nn=min(nn,a[i]);
cout<<nn;
return 0;
}
Làm giúp mình bài này với ạ,mình đang cần gấp
Em hãy viết chương trình Pascal để tính tổng của dãy số An(A1,A2,A3, ...,An) với n được nhập từ bàn phím.Em hãy viết chương trình để in ra tổng các số chẵn của dãy An
uses crt;
var x,n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
begin
readln(x);
if x mod 2=0 then t:=t+x;
end;
writeln(t);
readln;
end.
program ideone;
var i,n,x,res:longint;
begin
readln(n);
res:=0;
for i:=1 to n do
begin
read(x);
if x mod 2 = 0 then
res:=res+x;
end;
write(res);
end.
Viết chương trình nhập vào n số nguyên in ra màn hình tổng các số đó (giúp mình với ạ mình đang cần gấp)
Program HOC24;
var i,n: integer;
t: longint;
a: array[1..1000] of integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
t:=0;
for i:=1 to n do t:=t+a[i];
write('Tong la; ',t);
readln
end.