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,t;
int main()
{
freopen("dulieu.txt","r",stdin);
freopen("uot.txt","w",stdout);
cin>>n;
t=0;
for (i=1; i<=n; i++)
if (i%2==0) t+=i;
cout<<t;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
freopen("dulieu.txt","r",stdout);
freopen("ketqua.txt","w",stdout);
cin>>a>>b;
cout<<a+b;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long m,n,t,i;
int main()
{
freopen("dulieu.inp","r",stdin);
freopen("ketqua.out","w",stdout);
cin>>m>>n;
t=0;
for (i=m; i<=n; i++)
if (i%2!=0) t+=i;
cout<<t;
return 0;
}
uses crt;
const fi='songuyen.inp';
fo='songuyen2.out';
var a:array[1..100]of integer;
i,n,t1:integer;
f1,f2:text;
begin
clrscr;
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do readln(f1,a[i]);
t1:=0;
for i:=1 to n do if a[i] mod 2<>0 then t1:=t1+a[i];
writeln(t1);
writeln(f2,t1);
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
close(f1);
close(f2);
readln;
end.
const fi='bai1.inp';
fo='bai1.out';
var f1,f2:text;
a:array[1..100]of integer;
n,i,t,dem: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]);
t:=0;
dem:=0;
for i:=1 to n do
begin
if a[i] mod 2<>0 then t:=t+a[i]
else inc(dem);
end;
writeln(f2,'Tong cac so le la: ',t);
writeln(f2,'So so chan la: ',dem);
close(f1);
close(f2);
end.
a)
Input: Số nguyên dương N, dãy số a1,a2,a3,...,an
Output: Tổng các số chẵn nhỏ hơn hoặc bằng N
b)
Program HOC24;
var i,n: integer;
t: longint;
a: array[1..1000] of integer;
f1,f2: text;
const fi='SONGUYEN.TXT';
fo='SOCHAN.TXT';
begin
assign(f1,fi);
assign(f2,fo);
reset(f1);
rewrite(f2);
readln(f1,n);
for i:=1 to n do read(f1,a[i]);
for i:=1 to n do if (a[i] mod 2=0) and (a[i]<=n) then
begin
write(f2,a[i],' ');
t:=t+a[i];
end;
writeln(f2);
write(f2,t);
close(f1); close(f2);
end.
Uses crt;
var f1,f2:text;
i,n,tong,tongchan,dem:integer;
tb:real;
Begin
clrscr;
Assign(f1,'DAYSO.txt');
Assign(f2,'KETQUA.txt');
reset(f1);dem:=0;tong:=0;tongchan:=0;
While Not EOF(f1) do
Begin
read(f1,i);
inc(tong,i);
If i mod 2 = 0 then
begin
inc(dem);
inc(tongchan,i);
end;
End;
tb:=tongchan/dem;
close(f1);
rewrite(f2);
writeln(f2,tong);
writeln(f2,tongchan);
writeln(f2,tb:0:2);
close(f2);
write(tong);
readln;
End.
const fi='vao.inp';
fo='ra.out';
var n,i,s:integer;
f1,f2:text;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
s:=0;
for i:=1 to n do
s:=s+i;
writeln(f2,s);
close(f1);
close(f2);
end.