爱改名的小融 2(codevs 3149)

3149 爱改名的小融 2

 

 时间限制: 2 s
 空间限制: 128000 KB
 题目等级 : 黄金 Gold
 
 
题目描述 Description

Wikioi上有个人叫小融,他喜欢改名。
现在他的要求变了,只要是英文字母就是他的名字。
先给你N个名字,请你一一判断是不是小融。
本题还加强了测试数据

输入描述 Input Description

N
N行名字(全部为字符)

输出描述 Output Description

 N行,YES或NO(大写)

样例输入 Sample Input

3
&6*14315
Rinkement
micsloox

样例输出 Sample Output

NO

YES

YES

数据范围及提示 Data Size & Hint

对于40%的数据 N≤10 名字长度≤100
对于100%的数据 N≤50 名字长度≤100000

#include<cstdio>
#include<iostream>
#include<cstring>
#define M 100010
using namespace std;
char s[M];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int flag=0;
        cin>>s;
        int len=strlen(s);
        for(int j=0;j<len;j++)
          if((s[j]>='A'&&s[j]<='Z')||(s[j]>='a'&&s[j]<='z'));
          else
          {
              flag=1;
              printf("NO
");
              break;
          }
        if(!flag) printf("YES
");
    }
    return 0;
}
View Code
原文地址:https://www.cnblogs.com/harden/p/5619087.html