Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int player;
- bool fact = true, fict = false;
- int insert()
- {
- cin >> player;
- return player;
- }
- int game(int rnd)
- {
- cout << "\nEnter number between 0 and 100:";
- int x = insert();
- if (rnd != x)
- {
- if (rnd < x)
- {
- cout << "Number is lower\n";
- }
- else
- {
- cout << "Number is higher\n";
- }
- return 0;
- }
- else
- {
- cout << "YOU WIN!";
- return 1;
- }
- }
- int main()
- {
- int tries = 0;
- srand(static_cast<unsigned int>(time(0)));
- int rnd = rand() % 100 + 1;
- cout << "############\n";
- cout << rnd << endl;
- cout << "############\n\n";
- while (game(rnd) != 1)
- {
- tries++;
- game(rnd);
- }
- if (game(rnd) == 1)
- {
- cout << "It took " << tries << " tries!\n";
- cin >> player;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement