fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. void get_digits(vector<int>& digits, int num)
  6. {
  7. if (num > 9)
  8. get_digits(digits, num / 10);
  9. digits.push_back(num % 10);
  10. }
  11.  
  12. int main()
  13. {
  14. bool good;
  15. for (int i = 10000; i < 99999; i++)
  16. {
  17. if (i % 12 != 0)
  18. continue;
  19. good = 1;
  20. vector<int> digits;
  21. get_digits(digits, i);
  22. for (int j = 0; (good) && (j < 5); j++)
  23. for (int k = 0; k < 5; k++)
  24. {
  25. if (j == k)
  26. continue;
  27. if (abs(digits[j] - digits[k]) != 3)
  28. {
  29. good = 0;
  30. break;
  31. }
  32. }
  33. if (good)
  34. {
  35. cout << "number " << i;
  36. break;
  37. }
  38. good = 0;
  39. }
  40. if (!good)
  41. cout << "sosi pisos";
  42.  
  43. return 0;
  44. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
sosi pisos