int main() { int n = 0; cin >> n; for (int i = 0; i < n; ++i) { cout << 2 * i << endl; } return 0; } 2) #include <iostream> #include <cmath> using namespace std;
int main() { int a = 0, b = 0; cin >> a >> b; for (int i = a; i <= b; ++i) { cout << pow(i, 2) << endl; } return 0; } 3) #include <iostream> #include <cmath> using namespace std;
int main() { int a = 0, b = 0, sum = 0; cin >> a >> b; for (int i = a; i <= b; ++i) { sum += pow(i, 2); } cout << sum << endl; return 0; }
1) var a,b,s:integer; begin Readln(a,b); s:=0; if (a<0)and(b<0) then begin a:=-a; b:=-b; end; if a<0 then for var i:=1 to b do s+=a else for var i:=1 to a do s+=b; WriteLn(s); end.
Пример: -7 15 -105
2) var n,s:integer; begin Readln(n); s:=0; for var i:=1 to n do s+=i; WriteLn(s); end.
Пример: 100 5050
3) var a,b,s:integer; begin Readln(a,b); s:=0; for var i:=a to b do s:=s+i*i; writeLn(s); end.
Пример: 2 5 54
4) var a,b,n:integer; begin Readln(a,b,n); for var i:=1 to n do write(random(b-a+1)+a,' '); end.
#include <iostream>
using namespace std;
int main()
{
int n = 0;
cin >> n;
for (int i = 0; i < n; ++i) {
cout << 2 * i << endl;
}
return 0;
}
2)
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a = 0, b = 0;
cin >> a >> b;
for (int i = a; i <= b; ++i) {
cout << pow(i, 2) << endl;
}
return 0;
}
3)
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a = 0, b = 0, sum = 0;
cin >> a >> b;
for (int i = a; i <= b; ++i) {
sum += pow(i, 2);
}
cout << sum << endl;
return 0;
}
var a,b,s:integer;
begin
Readln(a,b);
s:=0;
if (a<0)and(b<0) then
begin a:=-a; b:=-b; end;
if a<0 then for var i:=1 to b do s+=a
else for var i:=1 to a do s+=b;
WriteLn(s);
end.
Пример:
-7 15
-105
2)
var n,s:integer;
begin
Readln(n);
s:=0;
for var i:=1 to n do s+=i;
WriteLn(s);
end.
Пример:
100
5050
3)
var a,b,s:integer;
begin
Readln(a,b);
s:=0;
for var i:=a to b do s:=s+i*i;
writeLn(s);
end.
Пример:
2 5
54
4)
var a,b,n:integer;
begin
Readln(a,b,n);
for var i:=1 to n do write(random(b-a+1)+a,' ');
end.
Пример:
10 20 5
11 12 14 14 18