#include <stdlib.h>
#include <time.h>
#include <iostream>
using namespace std;
#define N 16
void main()
{
int randomNumbers[N];
srand(time(NULL));
for (int i = 0;i < N; i++)
{
randomNumbers[i] = rand() % 40 - 20;
cout << "randomNumber[" << i << "] = " << randomNumbers[i] << endl;
}
cout << endl;
for (int i = 0; i < N; i++)
{
if (randomNumbers[i] % 2 == 0)
{
cout << i << endl;
}
}
}
ЗАДАНИЕ 1:
#include <iostream>
using namespace std;
void main()
{
int number = 0;
cout << "Введите число ->";
cin >> number;
if (number % 2 == 0)
{
number *= 3;
}
else
{
number /= 2;
}
cout << number << endl;
}
ЗАДАНИЕ 2:
#include <iostream>
#include <cctype>
using namespace std;
void main()
{
char symbol = 0;
cout << "Введите символ ->";
cin >> symbol;
if (isalpha(symbol))
{
cout << "Вы ввели букву" << endl;
}
else if (isdigit(symbol))
{
cout << "Вы ввели цифру" << endl;
}
else if (ispunct(symbol))
{
cout << "Вы ввели знак препинания" << endl;
}
else
{
cout << "Вы ввели не букву, не цифру и не знак препинания" << endl;
}
}
def main():
x = int(input("Enter number:\n"))
while (x < 1 or x > 30):
x = int(input("wrong input. Try again:\n"))
n = int(input("Ok. Now enter power of x:\n"))
print(x**n)
if __name__ == "__main__":
main()