fork download
  1.  
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <cstdio>
  5.  
  6. void result(const int *b) {
  7. double result = (double)b[0] + (13.0 * (double)b[1] / (double)b[2]) + (double)b[3] + (12.0 * (double)b[4]) - (double)b[5] - 11.0 + ((double)b[6] * (double)b[7] / (double)b[8]) - 10.0;
  8.  
  9. if (result == 66.0) {
  10. printf("%d + (13 * %d / %d) + %d + (12 * %d) - %d - 11 + (%d * %d / %d) - 10 = %d\n", b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], (int)result);
  11. }
  12. }
  13.  
  14. void calc() {
  15. int b[] = { 1, 2, 3, 4, 5, 6, 7 };
  16.  
  17. std::sort(b, b + sizeof(b) / sizeof(int));
  18.  
  19. do {
  20. result(b);
  21. } while (std::next_permutation(b, b + sizeof(b) / sizeof(int)));
  22. }
  23.  
  24.  
  25.  
  26. int main(int argc, char* argv[])
  27. {
  28. calc();
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty