Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main ( int argc, char * argv[] )
- {
- cout << "Zadejte n:" << endl;
- int n;
- cin >> n;
- if ( cin.fail() || n <= 0 )
- {
- cout << "Nespravny vstup" << endl;
- return 1;
- }
- cout << "Zadejte cisla" << endl;
- int c = 0, tmp;
- bool progress = false;
- for ( ; n != 0; n-- )
- {
- cin >> tmp;
- if ( cin.fail() )
- {
- cout << "Nespravny vstup" << endl;
- return 1;
- }
- if ( !progress )
- {
- if ( tmp % 2 == 0 )
- {
- c++;
- progress = true;
- }
- }
- else
- {
- if ( tmp % 2 != 0 )
- progress = false;
- }
- }
- cout << "Vysledek: " << c << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment