#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;
}
}
Поделитесь своими знаниями, ответьте на вопрос:
Рассчитать значение у при заданном значении х: cos² при х< 0 y =1 +cos²x в противном случае