Advertisement
desislava_topuzakova

05. Special Numbers

Feb 12th, 2024
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n;
  7. cin >> n;
  8.  
  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. //четирицифрено число: {thousands}{hundreds}{tens}{units}
  19. //проверка дали е специално
  20. if (n % thousands == 0 && n % hundreds == 0 && n % tens == 0 && n % units == 0)
  21. {
  22. cout << thousands << hundreds << tens << units << " ";
  23. }
  24.  
  25. }
  26. }
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement