Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <string>
  4. using namespace std;
  5. int main()
  6. {
  7. //Variables
  8.  
  9. string player1 = "";
  10. string player2 = "";
  11.  
  12. int guess1 = 0;
  13. int guess2 = 0;
  14. int guessCalc1 = 0;
  15. int guessCalc2 = 0;
  16.  
  17. int randNr = 0;
  18.  
  19.  
  20. randNr = rand() % 100 + 1;
  21.  
  22.  
  23. cout << "Please enter your name: \n";
  24. cin >> player1;
  25.  
  26. while (player1 != "Ingen");
  27. {
  28. cout << player1 << " wins!\n";
  29.  
  30. cout << "Enter your first guess: \n";
  31. cin >> guess1;
  32. cout << "Enter your second guess: \n";
  33. cin >> guess2;
  34.  
  35. guessCalc1 = abs(guess1);
  36. guessCalc2 = abs(guess2);
  37.  
  38. if (guessCalc1 > guessCalc2)
  39. {
  40. cout << "Enter your third guess: \n";
  41. cin >> guess2;
  42. guessCalc2 = abs(guess2);
  43. if (guessCalc2 > guessCalc1)
  44. {
  45. guessCalc1 = guessCalc2;
  46. }
  47. }
  48. else
  49. {
  50. cout << "Enter your third guess\n ";
  51. cin >> guess1;
  52. guessCalc1 = abs(guess1);
  53. if (guessCalc1 < guessCalc2)
  54. {
  55. guessCalc1 = guessCalc2;
  56. }
  57. }
  58.  
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement