#include <iostream>
#include <bitset>
#include <string>
#include <ctime>

using namespace std;

int getRandomNumber(int min, int max) {
	static const double fraction = 1.0 / (static_cast<double>(RAND_MAX) + 1.0);
	return static_cast<int>(rand() * fraction * (max - min + 1) + min);
}

int main() {
gotoPoint:
	srand(static_cast<unsigned int>(time(0)));
	rand();
	int reVar;
	reVar = getRandomNumber(1, 100);
	int enVar;
	cout << "Let's play a game. I'm thinking of a number. You have 7 tries to guess what it is." << endl;
	for (int i = 1; i < 8; i++) {
		cout << "\nGuess #" << i << ":";
		cin >> enVar;
		if (enVar > reVar) {
			cout << "Too high";
		}
		else if (enVar < reVar) {
			cout << "Too low";
		}
		else if (enVar == reVar) {
			cout << "You won";
			break;
		}

	}
	while (true) {
		cout << "\nWould you like to play again (y/n)?: ";
		string userAnswer;
		cin >> userAnswer;

		if (userAnswer == "y") {
			goto gotoPoint;
		}
		else if (userAnswer == "n") {
			cout << "Thank you for playing.";
			break;
		}
		else {
			cout << "Try again...";
		}
	}
}