编程语言
首页 > 编程语言> > 杭电OJ 2024(C++)

杭电OJ 2024(C++)

作者:互联网

C语言合法标识符

#include<iostream>
using namespace std;
#include<string>

int main()
{
	int i,j,n,k=0;
	string a;
	while(cin>>n)
	{
		getline(cin,a);
		for(i = 0 ; i < n ; i++)
		{	
			getline(cin,a);
			if(a[0] >= '0' && a[0]<= '9')
			{
				cout<<"no"<<endl;
				continue;
			}
			for(j = 0 ; j < a.size() ; j++)
			{
				if( (a[j] >= 'a' && a[j] <= 'z' ) || (a[j] >= 'A' && a[j] <= 'Z' )  ||  ( a[j] >= '0' && a[j]<= '9' ) || a[j] == '_')
					k++;
			}
			if(k == a.size())
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
			k = 0;
		}
	}
	return 0;
}

标签:std,2024,OJ,int,cin,杭电,&&,include,getline
来源: https://blog.csdn.net/evernight_17/article/details/118761648