#include<iostream> #include<cmath> using namespace std; main() { int a, suma=0, q=0; cin>>a; int tab[a], min=1002; for(int i=0; i<a; i++) { cin>>tab[i]; suma+=tab[i]; if(tab[i]%2!=0&&tab[i<min]) min=tab[i]; } if(suma%2==0) cout<<suma; else { if((suma-min)%2==0&&(suma-min)!=0) cout<<suma-min; else cout<<"NIESTETY"; } }
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 | #include<iostream> #include<cmath> using namespace std; main() { int a, suma=0, q=0; cin>>a; int tab[a], min=1002; for(int i=0; i<a; i++) { cin>>tab[i]; suma+=tab[i]; if(tab[i]%2!=0&&tab[i<min]) min=tab[i]; } if(suma%2==0) cout<<suma; else { if((suma-min)%2==0&&(suma-min)!=0) cout<<suma-min; else cout<<"NIESTETY"; } } |