标题:看不懂题目的真正意思,求助!
取消只看楼主
ClearningC
Rank: 2
等 级:论坛游民
帖 子:98
专家分:43
注 册:2016-10-26
结帖率:89.47%
已结贴  问题点数:20 回复次数:3 
看不懂题目的真正意思,求助!
Description
Your task is to determine whether a string is a valid variable name in C (for simplicity, you do not need to worry about whether a keyword is valid, that is, if the string is "int" or another key word, it is valid )
Input
The first line is the integer n, which indicates how many tests will be performed. Next, each line of the n lines is the string you need to determine.
Output
The output will contain n rows, each row being "Yes" or "No" depending on whether the corresponding string is a valid variable name
Sample input
5
abc
1yyy
hello
World
Yes%
Sample output
Yes
No
Yes
Yes
No



下面是我理解后写的代码,但是不合题意
#include<stdio.h>
#include<string.h>
int main()
{
    int n;
    scanf("%d",&n);
    char s[100];
    int i,length,b;
    for(i=1;i<=n;i++)
    {
        scanf("%s",s);
        length=strlen(s);
        for(int j=0;j<length;j++)
        {
            if((s[j]>='A'&&s[j]<='Z')||(s[j]>='a'&&s[j]<='z'))
                b=1;
            else
            {
                b=0;
                break;
            }
        }
        if(b==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}
搜索更多相关主题的帖子: performed determine keyword another contain 
2017-01-01 23:21
ClearningC
Rank: 2
等 级:论坛游民
帖 子:98
专家分:43
注 册:2016-10-26
得分:0 
回复 2楼 zbjzbj
在第二张截图里输入的第6行有下划线,但是输出确是No,所以我觉得下划线并不是有效字符。
2017-01-01 23:36
ClearningC
Rank: 2
等 级:论坛游民
帖 子:98
专家分:43
注 册:2016-10-26
得分:0 
回复 4楼 九转星河
我有用翻译器翻译过,但是还是不理解。
2017-01-01 23:53
ClearningC
Rank: 2
等 级:论坛游民
帖 子:98
专家分:43
注 册:2016-10-26
得分:0 
回复 6楼 吹水佬
原来是这样,明白了,谢谢!
2017-01-02 09:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-473200-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.604568 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved