注意字符串第一个字符不能是数字!!!
C语言合法标识符

#include<stdio.h>
#include<math.h>
#include<string.h> 
int main()
{
	int n,i,j,p,sum;
	char m[50];
	while(scanf("%d",&n)!=EOF)
	{
		getchar();
		for(i=0;i<n;i++)
		{
			p=0;
			gets(m);
			sum=strlen(m);
			if(m[0]=='_'||m[0]>='a'&&m[0]<='z'||m[0]>='A'&&m[0]<='Z')
			{
				for(j=1;j<sum;j++)
				{
					if(m[j]=='_'||m[j]>='a'&&m[j]<='z'||m[j]>='A'&&m[j]<='Z'||m[j]>='0'&&m[j]<='9')
					p++;
				}
					if(p==sum-1)
					printf("yes\n");
					else
					printf("no\n");
			}
			else
			printf("no\n");
		}
	}
	return 0;
}

相关文章:

  • 2022-01-27
  • 2022-03-07
  • 2021-12-21
  • 2021-12-23
  • 2022-01-07
  • 2022-01-19
  • 2021-11-23
猜你喜欢
  • 2022-01-21
  • 2022-02-07
  • 2022-01-29
  • 2021-12-17
  • 2021-11-23
相关资源
相似解决方案