Код на C++:
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
setlocale(LC_ALL, "rus");
srand(time(NULL));
int rows = 30;
int chairs = 0;
for (int i = 1, count_of_chairs = 20; i <= 30; i++, count_of_chairs += 2)
{
chairs += count_of_chairs;
}
cout << chairs << endl;
return 0;
};
Код на Python:
rows = 30
chairs = 0
count_of_chairs = 20
for i in range(1, 31, 1):
chairs += count_of_chairs
count_of_chairs += 2
print(chairs)
Объяснение:
MAX_SIZE = 10;
var
a: array[1..MAX_SIZE] of integer;
i, size: integer;
procedure delete_odd_elements();
var i, j: integer;
begin
i := 1;
repeat
if odd(a[i]) then
begin
dec(size);
for j := i to size do
a[j] := a[j + 1]
end
else inc(i);
until i > size;
end;
begin
writeln('Исходный массив: ');
size := MAX_SIZE;
for i := 1 to size do
begin
a[i] := random(100);
write(a[i] : 3);
end;
delete_odd_elements;
writeln;
writeln('Полученный массив: ');
for i := 1 to size do
write(a[i] : 3);
end.