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.
Program HOC24;
var i,t,k,n: integer;
begin
write('Nhap N: '); readln(n);
t:=0; k=0;
while k=0 do
begin
n:=n+1;
for i:=1 to n do if n mod i=0 then t:=t+i;
if t=n then
begin
write(n);
k:=k+1
end else t:=0;
end;
readln
end.
Bài 1:
uses crt;
var n,t1,t2,t3,i:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t1:=0;
t2:=0;
for i:=1 to n-1 do
begin
if i mod 2=1 then t1:=t1+i
else t2:=t2+i;
end;
writeln('Tong cac so le nho hon ',n,' la: ',t1);
writeln('Tong cac so chan nho hon ',n,' la: ',t2);
t3:=0;
for i:=1 to 2*n do
t3:=t3+i;
writeln('Tong cac so trong day so tu 1 toi 2*',n,' la: ',t3);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
double x,t;
int n,i;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
t=t+x;
}
cout<<"tong cac so la:"<<fixed<<setprecision(2)<<t<<endl;
cout<<"trung binh la:"<<fixed<<setprecision(2)<<t/(n*1.0);
return 0;
}
program TongSoChan;
var
n, i, x, tong: integer;
begin
write('Nhap so nguyen n: ');
readln(n);
tong := 0;
for i := 1 to n do
begin
read(x);
if x mod 2 = 0 then
tong := tong + x;
end;
writeln('Tong cac so chan la: ', tong);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
string n;
int d,i,t,x;
int main()
{
freopen("tong.inp","r",stdin);
freopen("tong.out","w",stdout);
cin>>st;
d=st.length();
t=0;
for (i=0; i<=d; i++)
{
x=int(st[i])-48;
t=t+x;
}
cout<<t;
return 0;
}
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long n,x,i,t1,t2;
int main()
{
cin>>n;
t1=0; t2=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) t1=t1+x;
else t2=t2+x;
}
cout<<t1<<" "<<t2;
return 0;
}