判断输入是数字还是字符串

#include <iostream>
using namespace std;
int main()
{
while(true)
{ char temp;
cin >> temp;
if ( (temp <= 'Z' && temp >= 'A') || (temp <= 'z' && temp >= 'a') )
cout << temp << " is character" << endl;
else if (temp >= '0' && temp <= '9')
cout << temp << " is number" << endl;
}
}
posted @ 2021-05-16 18:10  Maguyusi  阅读(8)  评论(0)    收藏  举报  来源