Загрузить файлы в «/»
This commit is contained in:
28
main.cpp
Normal file
28
main.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int sum = 0;
|
||||
int proizv = 1;
|
||||
list<int> N{1, 2, 3, 4, 5, 6, 7};
|
||||
|
||||
for (int n : N) {
|
||||
int a = 2;
|
||||
div_t result = div(n, a);
|
||||
if (result.rem == 0) {
|
||||
printf("четное ");
|
||||
cout << n << endl;
|
||||
sum += n;
|
||||
} else {
|
||||
printf("не четное ");
|
||||
cout << n << endl;
|
||||
proizv *= n;
|
||||
}
|
||||
}
|
||||
cout << "Сумма четных чисел: " << sum << endl;
|
||||
cout << "Произведение нечетных чисел: " << proizv << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user