#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

class UpDownGame {
private:
    int answer;
public:
    UpDownGame() {
        srand(time(0));
        answer = rand() % 100 + 1;
    }

    void play() {
        int guess;
        while (true) {
            cin >> guess;
            if (guess > answer) cout << "Down" << endl;
            else if (guess < answer) cout << "Up" << endl;
            else { cout << "정답!" << endl; break; }
        }
    }
};

int main() {
    UpDownGame game;
    game.play();
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: