問題の処理:1~9までの数字を入力する際、不正入力されたとき再入力をさせる処理
// C++の再入力処理.
#include<iostream>
using namespace std;
int main() {
int num;
// 1~9が入力されていなければ再入力
cout << "Please enter the numbers(1-9) --> ";
while(1) {
cin >> num;
if(num > 0 && num < 10)break;
cout << "Please enter it again.(1-9) -->";
}
return 0;
}
このとき、半角英数字「a」を入力すると.......
