#include <iostream>
int main() {
const int SIZE = 10;
bool isSence = false;
int sum = 0;
int count = 0;
int arr[SIZE];
for (int i = 0; i < SIZE; i++)
{
arr[i] = rand() % 20 - 10; // "рандомно" заполняем массив от -10 до 10
std::cout << arr[i] << "\t"; // выводим массив в консоль
if (arr[i] >= 0)
isSence = true;
}
for (int i = 0; i < SIZE; i++)
{
if ((isSence) && (arr[i] > 0))
sum += arr[i]; //sum = sum + arr[i];
count++;
}
if (isSence)
std::cout << "\nсреднее арифметическое положительных чисел = " << double(sum) / count << std::endl; // явное приведение типов
else
std::cout << "\nВ массиве нету положительных чисел или нету нулей и/или отрицательных чисел" << std::endl;
return 0;
}
var
brackets: array [0..2, 0..1] of char := (('{', '}'), ('[', ']'), ('(', ')'));
begin
var s := ReadlnString();
var counter := 0;
var max_depth := 0;
for var i := 1 to s.Length do
begin
if s[i] = '(' then counter += 1
else if s[i] = ')' then counter -= 1
else continue;
if counter < 0 then begin
writeln('brackets error');
Halt;
end;
if counter > max_depth then max_depth := counter;
end;
counter := 0;
for var i := 1 to s.Length do
begin
if s[i] = '(' then counter += 1
else if s[i] = ')' then counter -= 1
else continue;
if (counter = max_depth - 1) and (s[i] = '(') then s[i] := brackets[1, 0]
else if (counter = max_depth - 2) and (s[i] = ')') then s[i] := brackets[1, 1]
else if (counter = max_depth - 2) and (s[i] = '(') then s[i] := brackets[0, 0]
else if (counter = max_depth - 3) and (s[i] = ')') then s[i] := brackets[0, 1];
end;
writeln(s);
end.