C++中如何判断输入的一个或两个字符是数字还是英文

来源:百度知道 编辑:UC知道 时间:2024/05/28 02:32:09
要具体程序 呵呵 谢谢了

其实没有那么复杂了~在标准C里,有这么一些函数:
#include<stype.h>
int isdigit(int c);
int isalpha(int c);

#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;
}
}