user input check int only

后端 未结 4 475
抹茶落季
抹茶落季 2021-01-21 11:34

I am trying to have my user input not crash my program by restricting what the user can input such as:

  1. only being an int
  2. being between 1-30
<
4条回答
  •  有刺的猬
    2021-01-21 12:03

    do:
    get number from user
    if non integer format is entered{
    number = -1;}
    while: 1 < number < 30
    

提交回复
热议问题