desislava_topuzakova

01. Number Pyramid начин 2

Feb 14th, 2021
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.     //четирицифрени числа: 1111 до 9999
  10.     for (int thousands = 1; thousands <= 9; thousands++)
  11.     {
  12.         for (int hundreds = 1; hundreds <= 9; hundreds++)
  13.         {
  14.             for (int tens = 1; tens <= 9; tens++)
  15.             {
  16.                 for (int units = 1; units <= 9; units++)
  17.                 {
  18.                     bool check1 = n % thousands == 0;
  19.                     bool check2 =  n % hundreds == 0;
  20.                     bool check3 =  n % tens == 0;
  21.                     bool check4 = n % units == 0;
  22.  
  23.                     if (check1 && check2 && check3 && check4) {
  24.                         cout << thousands << hundreds << tens << units << " ";
  25.                     }
  26.                 }
  27.             }
  28.         }
  29.     }
  30.  
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment