Description
输入一个字符串,判断其是否是C的合法标识符。
Input
输入一个长度不超过50的字符串。
Output
如果输入数据是C的合法标识符,则输出"yes",否则,输出“no”。
Sample Input
8fixafghgjhjhjyuyuyyuyuyu
Sample Output
no
HINT
Source
//标识符由字母、下划线、数字这三个方面组成,但开头必须是字母或下划线。另外,关键字不能是标识符
#include <stdio.h>
#include <stdlib.h>
#include<ctype.h>
int main()
{
char str[51];
int i=0;
gets(str);
if(str[i]!='_'&&!isalpha(str[i]))
{
printf("no");
return 0;
}
for(; str[i]!='\0'; i++)
{
if(isdigit(str[i]));
else if(isalpha(str[i]));
else if(str[i]=='_');
else
{
printf("no");
return 0;
}
}
printf("yes");
return 0;
}