Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // Dice
- //
- // Created by Jean Olivier Ortega on 4/23/17.
- // Copyright © 2017 Jean Olivier Ortega. All rights reserved.
- //
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- srand(static_cast<unsigned int> (time(0)));
- int pcGuess;
- int guess;
- int tries = 0;
- cout << "Insert your number: " << endl;
- cin >> guess;
- do{
- if(pcGuess != guess){
- pcGuess = rand()% 100 + 1;
- tries++;
- }
- } while(pcGuess != guess);
- cout << "We found your number! The computer tried " << tries << " times to find your secret number! " << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement