#include <iostream>
#include <string>
#include <conio.h>
#define ESC 27
using namespace std;
int main() {
char ch;
int sum = 0;
do {
ch = _getch();
if (ch == ESC) {
cout << "Output of the program:\n" << sum;
putchar('\n');
} else {
cout << ch;
sum += (int)ch;
putchar('\n');
}
} while (ch != ESC);
system("pause");
return 0;
}
Объяснение:
Dim Massiv(9) as Integer ' Объявляем массив из 9 элементов
Dim Composition as Integer ' Результат произведения нечетных элементов массива
Dim index as Integer ' Индекс для доступа к элементам массива
' Заполняем массив случайными числами
For index = 0 to 9
Massiv(index) = Rnd() * 5
print Massiv(index) ' Вывод массива
Next
' Инициализируем переменную Composition
Composition = 1
For index = 0 to 9
If Massiv(index) Mod 2 <> 0 Then ' Если элемент не четный то выполнить произведение
Composition = Composition * Massiv(index)
End if
Next
print Composition ' Результат произведения