fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string player1;
  8. string player2;
  9. int anumber;
  10. int bnumber;
  11. int x;
  12. int y;
  13. cout << "Player 1 Enter Your Name" << endl;
  14. cin >> player1;
  15. cout << "Player 2 Enter Your Name" << endl;
  16. cin >> player2;
  17. cout << player1 << ", Enter Your Number" << endl;
  18. cin >> anumber;
  19. cout << player2 << ", Enter Your Number" << endl;
  20. cin >> bnumber;
  21. while(true) {
  22. cout << player1 << ", Try to Guess " << player2 << "'s number" << endl;
  23. cin >> x;
  24. if(x==bnumber){
  25. cout << "You Win!" << endl;
  26. break;
  27. }
  28. else if(x>bnumber){
  29. cout << "Too High" << endl;
  30. }
  31. else if(x<bnumber){
  32. cout << "Too Low" << endl;
  33. }
  34. cout << player2 << ", Try to Guess " << player1 << "'s number" << endl;
  35. cin >> y;
  36. if(y==anumber){
  37. cout << "You Win!" << endl;
  38. break;
  39. }
  40. else if(y>anumber){
  41. cout << "Too High" << endl;
  42. }
  43. else if(y<anumber){
  44. cout << "Too Low" << endl;
  45. }
  46. }
  47. return 0;
  48. }
  49.  
Success #stdin #stdout 0s 3024KB
stdin
Aaron Dylan 15 15 10 6 15
stdout
Player 1 Enter Your Name
Player 2 Enter Your Name
Aaron, Enter Your Number
Dylan, Enter Your Number
Aaron, Try to Guess Dylan's number
Too Low
Dylan, Try to Guess Aaron's number
Too Low
Aaron, Try to Guess Dylan's number
You Win!