Advertisement
Qpel

ciklai 4 užd

Mar 19th, 2017
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.     int n = 0, laik, dlaik, a, sk, nk;
  9.  
  10.     for(int i = 1; i < 99999; i++){
  11.     laik = i;
  12.     dlaik = i;
  13.     //cout << n << endl;
  14.     sk = 0; nk =0;
  15.  
  16.  
  17.     while (dlaik > 0){
  18.         dlaik = dlaik / 10;
  19.         sk++;
  20.     }
  21.  
  22.     dlaik = i;
  23.  
  24.     for(int i = 0; i < sk; i++){
  25.         a = dlaik % 10;
  26.         dlaik = dlaik / 10;
  27.         if(a!= 0 and laik % a == 0) nk++;
  28.     }
  29.  
  30.     if(sk == nk){
  31.         n++;
  32.         cout << i << endl;
  33.     }
  34.  
  35.     if(n == 40) break;
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement