-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathminisessia.cpp
More file actions
36 lines (35 loc) · 946 Bytes
/
Copy pathminisessia.cpp
File metadata and controls
36 lines (35 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;
void main()
{
setlocale(LC_ALL, "Russian");
int n;
cout << "Введите N: ";
cin >> n;
while (n < 1)
{
cout << "[X] Введите положительное число N: ";
cin >> n;
}
cout << "Введите " << n << " целых чисел" << endl;
int a, min,
mod3 = 0,
proizvedenie = 1,
primes = 0;
for (int i = 0, j; i < n; i++)
{
cin >> a;
if (a % 3 == 0) mod3++;
if (a > 0) proizvedenie *= a;
if (a >= 2) {
for (j = 2; (j < a) && (a % j != 0); j++)
;
if (a == j) primes++;
}
if ((i == 0) || (min > a)) min = a;
}
cout << "Количество чисел кратных 3 = " << mod3 << endl;
cout << "Произведение неотрицательных чисел = " << proizvedenie << endl;
cout << "Количество простых чисел = " << primes << endl;
cout << "Минимальное число = " << min << endl;
}