fork(2) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. int main(int argc, char * argv[])
  8. {
  9. int x[] = {3,4,5,6,7,8,9,10,11};
  10.  
  11. do {
  12. if (x[0]*x[1]*x[2] != x[0]*x[3]*x[6]) continue;
  13. if (x[1]*x[4]*x[7] != x[3]*x[4]*x[5]) continue;
  14. if (x[2]*x[5]*x[8] != x[6]*x[7]*x[8]) continue;
  15.  
  16. for(int i = 0; i < 9; ++i)
  17. {
  18. cout << setw(3) << x[i];
  19. if (i%3 == 2) cout << "\n";
  20. }
  21. cout << "\n\n";
  22. break;
  23.  
  24. } while(next_permutation(x,x+9));
  25.  
  26. }
  27.  
Success #stdin #stdout 0.01s 5564KB
stdin
Standard input is empty
stdout
  7  3  8
  6  9  5
  4 10 11