C++判断输入是否是数字输入

#include <iostream>
using namespace std;

int main(){
    int number;
    if (!(cin >> number)){
        cout << "非数字输入\n";
    }
    else
    {
        cout << "数字输入!";
    }

    system("pause");
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/Toya/p/9266509.html