#include <iostream> using namespace std; int main() { int n, il_np = 0, mn_np = 1001, suma = 0, pom; cin >> n; for(int i = 0; i < n; i++) { cin >> pom; suma = suma + pom; if(pom%2 == 1) { il_np++; mn_np = min(mn_np, pom); } } if(il_np == 1 && n == 1) { cout << "NIESTETY"; } else { if(suma%2 == 1) { cout << suma-mn_np; } else { cout << suma; } } }
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 | #include <iostream> using namespace std; int main() { int n, il_np = 0, mn_np = 1001, suma = 0, pom; cin >> n; for(int i = 0; i < n; i++) { cin >> pom; suma = suma + pom; if(pom%2 == 1) { il_np++; mn_np = min(mn_np, pom); } } if(il_np == 1 && n == 1) { cout << "NIESTETY"; } else { if(suma%2 == 1) { cout << suma-mn_np; } else { cout << suma; } } } |