int main() { string answer = "0000"; //正答 string input = "0000"; //入力用 srand((unsigned int)(time(nullptr))); MakeProblem(answer); cout << "THE HIT AND BLOW GAME" << endl; cout << "Let's Play the GAME!!" << endl; while (true) { cout << "予想した4桁の整数を入力:"; cin >> input; if (エラー処理で問題なかったら) { if(もし正解だったら) break;//どうせ正解したらループ抜けちゃうから、elseと書かなくてすむ //HIT数を数えて表示 cout << " Hit:" << HIT数カウント呼び出し << endl; //BLOW数を数えて表示 cout << "Blow:" << BLOW数カウント呼び出し << endl; } } //正解した時しかここにたどり着かない。 //ループの中で処理してもいいけど、今回はこんな感じにしてみました。 cout << "おめでとう!" << endl; cout << "答えは" << answer << "でした" << endl; return 0; }