fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int a, b, c;
  8. int k = 100;
  9.  
  10. // finds three natural numbers a, b, and c,
  11. // such that all of the following holds
  12. // a) a < b < c
  13. // b) a + b + c = 100
  14. // c) a * b * c = 7680
  15.  
  16. for (a = 1; a<100; a++) // a cannot be more than 100
  17. for (b = 1; b<100; b++) // b cannot be more than 100
  18. for (c = 1; c<100; c++) // c cannot be more than 100
  19. if ( ( a < b ) &&
  20. ( b < c ) &&
  21. ( a+b+c == 100 ) &&
  22. ( a*b*c == 7680 ) )
  23. {
  24. // since we found it and we only wanted to find one such
  25. // triple, we print it out and return 0 from main, termi-
  26. // nating the execution of the program
  27.  
  28. cout << a << " " << b << " " << c << endl;
  29.  
  30. return 0;
  31. }
  32.  
  33. // return 0 from main (this return statement is only reached
  34. // if we fail to find the triple we're looking for)
  35.  
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
8 12 80