Advertisement
Guest User

Nothing interesting

a guest
Mar 1st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3.  
  4. using namespace std;
  5.  
  6. string num_to_str(int num)
  7. {
  8.     stringstream s;
  9.     s << num;
  10.     string a = s.str();
  11.     return a;
  12. }
  13. int main ()
  14. {
  15.     int num0, num5;
  16.     string num;
  17.     int counter = 0;
  18.     for(int i = 100005;i<=999500;i++)
  19.     {
  20.         num0 = 0;
  21.         num5 = 0;
  22.         num = num_to_str(i);
  23.         for(int j = 0;j<6;j++)
  24.         {
  25.             if(num[j] == '0') num0++;
  26.             if(num[j] == '5') num5++;
  27.         }
  28.         if(num0 >= 3 && num5 >= 1)
  29.         {
  30.             counter++;
  31.             cout << i << endl;
  32.         }
  33.     }
  34.     cout << endl << "ilosc: " << counter << endl;
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement