Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int main () {
  7.  
  8. int i, dificuldade, numero, tentativa, flag, flagb;
  9. srand(time(0));
  10.  
  11. flag = 0;
  12. flagb = 0;
  13.  
  14. do{
  15. do{
  16. cout << "Select A Dificulty (1 = Easy / 2 = Medium / 3 = Hard): ";
  17. cin >> dificuldade;
  18. }while (dificuldade != 1 && dificuldade != 2 && dificuldade != 3 && dificuldade != 69);
  19.  
  20. //------------------ 1 ---------------------//
  21.  
  22. if(dificuldade == 1){
  23. numero = rand() % 100 + 1;
  24. if(numero < 1)
  25. numero = numero * -1;
  26.  
  27. for(i=0;i<9;i++){
  28. cout << endl << "Insert A Number: ";
  29. cin >> tentativa;
  30. if (numero == tentativa){
  31. flag = 1;
  32. cout << endl << "You Won." << endl;
  33. break;
  34. }
  35. else{
  36. if (numero > tentativa)
  37. cout << endl << "Low. You Have " << 8-i << " Tries." << endl;
  38. if (numero < tentativa)
  39. cout << endl << "High. You Have " << 8-i << " Tries." << endl;
  40. }
  41. }
  42. }
  43.  
  44. //------------------ 2 --------------------//
  45.  
  46. if(dificuldade == 2){
  47. numero = rand() % 100 + 1;
  48. if(numero < 1)
  49. numero = numero * -1;
  50.  
  51. for(i=0;i<7;i++){
  52. cout << endl << "Insert A Number: ";
  53. cin >> tentativa;
  54. if (numero == tentativa){
  55. flag = 1;
  56. cout << endl << "You Won." << endl;
  57. break;
  58. }
  59. else{
  60. if (numero > tentativa)
  61. cout << endl << "Low. You Have " << 6-i << " Tries." << endl;
  62. if (numero < tentativa)
  63. cout << endl << "High. You Have " << 6-i << " Tries." << endl;
  64. }
  65. }
  66. }
  67.  
  68. //------------------- 3 -------------------//
  69.  
  70. if(dificuldade == 3){
  71. numero = rand() % 200 + 1;
  72. if(numero < 1)
  73. numero = numero * -1;
  74.  
  75. for(i=0;i<7;i++){
  76. cout << endl << "Insert A Number: ";
  77. cin >> tentativa;
  78. if (numero == tentativa){
  79. flag = 1;
  80. cout << endl << "You Won." << endl;
  81. break;
  82. }
  83. else{
  84. if (numero > tentativa)
  85. cout << endl << "Low. You Have " << 6-i << " Tries." << endl;
  86. if (numero < tentativa)
  87. cout << endl << "High. You Have " << 6-i << " Tries." << endl;
  88. }
  89. }
  90. }
  91.  
  92. if (dificuldade == 69){
  93. cout << endl << "Really?" << endl;
  94. flag = 1;
  95. }
  96.  
  97. if (flag == 0)
  98. cout << endl << "You Lost. The Number was: " << numero << endl;
  99.  
  100. cout << endl << "Want To Play Again? (0 = No / 1 = Yes): ";
  101. cin >> flagb;
  102. if (flagb == 1)
  103. cout << endl;
  104.  
  105. }while(flagb == 1);
  106.  
  107. return 0;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement