为什么当输入一个字母后加数字输出no,而两个字母加数字就成yes了呢,请解答
输入一个字符串,判断其是否是C的合法标识符。#include<stdio.h>
#include<string.h>
int main()
{
char s[60];
int n,m,i,k;
while( scanf( "%d",&n ) != EOF )
{
while( n-- )
{
getchar();
gets( s );
k = 0;
m = strlen( s );
if( s[0] <'A' || s[0] >'Z' )
if( s[0] < 'a' || s[0] > 'z' )
if( s[0] != '_')
k = 1;
if( !k )
for( i = 1; i < m; i++ )
{
if( s[i] < '0' || s[i] > '9')
if( s[i] < 'A' || s[i] > 'Z' )
if( s[i] <'a' || s[i] > 'z' )
if( s[i] != '_' )
{
k = 1;
break;
}
}
if( k )
printf( "no\n" );
else
printf( "yes\n" );
}
}
return 0;
}