Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- 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 num, c = 0;
- string txt;
- for ( ; n != 0; n-- )
- {
- cin >> num;
- if ( cin.fail() )
- {
- cout << "Nespravny vstup" << endl;
- return 1;
- }
- txt = to_string(num); // to_string je az v c++11, proto prekladej s prepinacem -std=c++11, napriklad g++ -std=c++11 tmp.cpp
- if ( txt.find_first_of("7") != string::npos )
- c++;
- }
- cout << "Vysledek: " << c << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment