Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <time.h>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. void mainfunc();
  9.  
  10. void retry();
  11.  
  12. void retry()
  13. {
  14.  
  15. int y;
  16. while(1)
  17. {
  18. cin >> y;
  19. if(strncmp(&y, "y", 1)==0);
  20.  
  21.  
  22. {
  23.  
  24.  
  25.  
  26. mainfunc();
  27.  
  28. }
  29.  
  30.  
  31. else return;
  32.  
  33.  
  34.  
  35. }
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. void mainfunc()
  70. { int x;
  71. int a;
  72. string name;
  73.  
  74.  
  75.  
  76.  
  77. srand((unsigned int)time(NULL));
  78.  
  79. a = rand()%10+1;
  80.  
  81. cout << "Enter your name, player! \n";
  82. cin >> name;
  83. cout << "\n Welcome, ";
  84. cout << name;
  85.  
  86.  
  87.  
  88. cout << " \n";
  89. cout << " \n";
  90. cout << "Guess the number between 1 and 10! It changes every time!: ";
  91. cin >> x;
  92. if (x>a){ cout << "The number was lower \n"; cout << "YOU FAIL!, "; cout << name;
  93. cout << " \n";
  94. cout << " \n";}
  95. if (x<a){ cout << "The number was higher \n";
  96. cout << "YOU FAIL!, "; cout << name;
  97. cout << " \n";
  98. cout << " \n";}
  99. if (x==a){ cout << "WINNER IS YOU \n";}
  100.  
  101. cout << " \n";
  102.  
  103.  
  104.  
  105. }
  106.  
  107.  
  108. int main ()
  109. {
  110. mainfunc();
  111. cout << "Hit the Y key then ENTER to close the program, otherwise, press just press ENTER. \n";
  112. retry();
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120. system("pause");
  121. return 0;
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement