#include <iostream> using namespace std; int n, w, pa, ni, suma, naj; int main() { cin >> n; int tab[n]; for (int i=0; i<n; i++){ cin >> tab[i]; w = tab[i]; /*if(w % 2 == 0){ //cout << tab[i]; }*/ suma = suma + tab[i]; if (w > naj && w % 2 != 0) naj = w; } suma = suma - naj; if(suma > 2) { cout << suma; } else if(suma < 2){ cout << "NIESTETY"; } return 0; }
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 | #include <iostream> using namespace std; int n, w, pa, ni, suma, naj; int main() { cin >> n; int tab[n]; for (int i=0; i<n; i++){ cin >> tab[i]; w = tab[i]; /*if(w % 2 == 0){ //cout << tab[i]; }*/ suma = suma + tab[i]; if (w > naj && w % 2 != 0) naj = w; } suma = suma - naj; if(suma > 2) { cout << suma; } else if(suma < 2){ cout << "NIESTETY"; } return 0; } |