Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // Dice
  4. //
  5. // Created by Jean Olivier Ortega on 4/23/17.
  6. // Copyright © 2017 Jean Olivier Ortega. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <cstdlib>
  11. #include <ctime>
  12.  
  13. using namespace std;
  14.  
  15. int main()
  16. {
  17.  
  18. srand(static_cast<unsigned int> (time(0)));
  19.  
  20. int pcGuess;
  21.  
  22. int guess;
  23. int tries = 0;
  24.  
  25. cout << "Insert your number: " << endl;
  26. cin >> guess;
  27.  
  28. do{
  29.  
  30. if(pcGuess != guess){
  31. pcGuess = rand()% 100 + 1;
  32. tries++;
  33. }
  34.  
  35. } while(pcGuess != guess);
  36.  
  37. cout << "We found your number! The computer tried " << tries << " times to find your secret number! " << endl;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement