fork(2) download
  1. #include <iostream>
  2.  
  3. bool rytual( int x, int & k, int & l ) {
  4. while( x > 1 ) {
  5. if(( k + l ) == 15 ) {
  6. return false;
  7. }
  8. if( x % 2 == 0 ) {
  9. k++;
  10. x /= 2;
  11. }
  12. else {
  13. x = 3 * x + 1;
  14. l++;
  15. }
  16. }
  17. if( x == 1 ) {
  18. return true;
  19. }
  20. }
  21.  
  22. int main() {
  23. int x;
  24. while( x != 0 ) {
  25. int kwiaty = 0, liscie = 0;
  26. std::cin >> x;
  27. if( rytual( x, kwiaty, liscie ) == true ) {
  28. std::cout < "TAK" << " " << kwiaty << " " << liscie << std::endl;
  29. }
  30. else if( rytual( x, kwiaty, liscie ) == false && x != 0 ) {
  31. std::cout << "NIE" << std::endl;
  32. }
  33. }
  34. return 0;
  35. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:28:34: error: invalid operands of types ‘const char [4]’ and ‘const char [2]’ to binary ‘operator<<’
             std::cout < "TAK" << " " << kwiaty << " " << liscie << std::endl;
                                  ^
prog.cpp: In function ‘bool rytual(int, int&, int&)’:
prog.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty