首页 > 编程语言 > 详细

c语言合法标识符

时间:2015-07-19 11:36:02      阅读:348      评论:0      收藏:0      [点我收藏+]

#include <iostream>
#include <stdio.h>
using namespace std;
char str[100][51];
int main()
{
int i,j,n,f,t;

cin>>n;getchar();
for(i=1;i<=n;i++)
{
gets(str[i]);
for(j=0;str[i][j]!=‘\0‘;j++)
t=j;
f=0;
if((str[i][0]>=‘A‘&&str[i][0]<=‘Z‘)||(str[i][0]>=‘a‘&&str[i][0]<=‘z‘)||str[i][0]==‘_‘)
{
f=1;
for(j=1;j<=t;j++)
{
if((str[i][j]>=‘0‘&&str[i][j]<=‘9‘)||(str[i][j]>=‘A‘&&str[i][j]<=‘Z‘)||(str[i][j]>=‘a‘&&str[i][j]<=‘z‘)||str[i][j]==‘_‘) {f=1;}
else {f=0;break;}
}
}
else f=0;
if(f==1) cout<<"yes"<<endl;
else cout<<"no"<<endl;
}
return 0;
}

c语言合法标识符

原文:http://www.cnblogs.com/NYNU-ACM/p/4658265.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!