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.
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long x,y;
int main()
{
cin >>x>>y;
cout<<x<<" "<<y;
swap(x,y);
cout<<x<<" "<<y;
return 0;
}
Sửa đề: S=1/1+1/2+1/3+...+1/n
uses crt;
var n,i:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
for i:=1 to n do
s:=s+1/i;
writeln(s:4:2);
readln;
end.
program tong;
uses crt;
var n,i:integer;
t:longint;
begin
clrscr;
write('nhap n:'); readln(n);
t:=0;
for i:=1 to n do
t:=t+1/i;
writeln(t);
readln;
end.
1:
uses crt;
var n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
t:=t+i*i;
write(t);
readln;
end.
2
program bt2;
var i,n,t:integer;
begin
readln(n);
s:=0;
for i:=1 to n do
if i mod 2 = 1 then s:=s+i;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long s,i,n;
int main()
{
cin>>n;
s=0;
for (i=1; i<=n; i++)
s=s+i;
cout<<s;
return 0;
}
program Tingtongs;
uses crt;
var n,i:integer; s:longint;
begin
clrscr;
write('nhap n:'); readln(n);
for i:=1 to n do s:=s+i;
write('Tong la: ',s);
readln;
end.
var i,n,s:integer;
begin
write('nhap n = ');readln(n);
i:=1;
while i<=n do
begin
s:=s+i;
i:=i+1;
end;
write('Tong la ',s);
readln;
end.
int main()
{
int n;
long s;
s=0;
i=1;
printf("\nSo n la: ");
scanf("%d",&n);
for(int i=1; i<=n; i++)
{
s=s+i;
}
printf("\nTổng %d là %ld: ", n, s);
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
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 n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
if (i%2!=0) t+=i;
cout<<t;
return 0;
}
a: uses crt;
var s,i,n:integer;
begin
clrscr;
readln(n);
s:=0;
for i:=1 to n do s:=s+i;
writeln(s);
readln;
end.
b:
uses crt;
var s:real;
i,n:integer;
begin
clrscr;
readln(n);
s:=0;
for i:=1 to n do
s:=s+1/i;
writeln(s:4:2);
readln;
end.
c:
uses crt;
var s:real;
i,n:integer;
begin
clrscr;
readln(n);
s:=0;
for i:=1 to n do
s:=s+1/i;
writeln(s+1/(n+1):4:2);
readln;
end.
Var i,S,n: longint;
Begin
Readln(n);
For i:=1 to n do S:=S+i
Write(S);
Readln
End.
program Tinh_tong;
Var n: integer;
s: longint;
BEGIN
repeat
write( 'Nhap n: '); readln(n);
until (n>=0);
s:=0;
for i:=1 to n do
s:=s+i;
write('Tong cac so tu 1 toi ', n,' =', s);
readln
END.