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.
using namespace std;
int main()
{
size_t N = 0, val = 0, count = 0;
cin >> N;
if (N < 100) {
for(size_t i = 0; i < N; ++i) {
cin >> val;
if (val < 300) {
if (!(val % 3)) ++count;
} else {
cout << "Value must be < 300" << endl;
exit(1);
}
}
} else {
cout << "N must be < 100" << endl;
}
cout << "Count: " << count << 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