Skip to content

Commit

Permalink
修复选择难度输入字母崩溃
Browse files Browse the repository at this point in the history
  • Loading branch information
lingdianlink committed Jul 12, 2020
1 parent 9801f84 commit 905d3d3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ int inputDifficulty()
std::string cmd;
while (1)
{
std::cout << "设置难度:1简单 2普通 3困难" << std::endl;

std::cin >> cmd;
while(1)
{
std::cout << "设置难度:1简单 2普通 3困难" << std::endl;

std::cin >> cmd;
if( cmd == "1" || cmd == "2" || cmd == "3" )
break;
std::cout << "输入错误!" << std::endl;
}
Difficulty difficulty = static_cast<Difficulty>(std::stoi(cmd));

switch (difficulty)
Expand Down

0 comments on commit 905d3d3

Please sign in to comment.