Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 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(x,y,z) == 0);
  20.  
  21. }
  22.  
  23.  
  24. {
  25. mainfunc();
  26. }
  27. else return;
  28.  
  29. }
  30.  
  31.  
  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. void mainfunc()
  66. { int x;
  67. int a;
  68. string name;
  69.  
  70.  
  71.  
  72.  
  73. srand((unsigned int)time(NULL));
  74.  
  75. a = rand()%10+1;
  76.  
  77. cout << "Enter your name, player! \n";
  78. cin >> name;
  79. cout << "\n Welcome, ";
  80. cout << name;
  81.  
  82.  
  83.  
  84. cout << " \n";
  85. cout << " \n";
  86. cout << "Guess the number between 1 and 10! It changes every time!: ";
  87. cin >> x;
  88. if (x>a){ cout << "The number was lower \n"; cout << "YOU FAIL!, "; cout << name;
  89. cout << " \n";
  90. cout << " \n";}
  91. if (x<a){ cout << "The number was higher \n";
  92. cout << "YOU FAIL!, "; cout << name;
  93. cout << " \n";
  94. cout << " \n";}
  95. if (x==a){ cout << "WINNER IS YOU \n";}
  96.  
  97. cout << " \n";
  98.  
  99.  
  100.  
  101. }
  102.  
  103.  
  104. int main ()
  105. {
  106. mainfunc();
  107. cout << "Hit the Y key then ENTER to close the program, otherwise, press just press ENTER. \n";
  108. retry();
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116. system("pause");
  117. return 0;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement