zoukankan      html  css  js  c++  java
  • AC日记——合法C标识符 openjudge 1.7 06

    06:合法 C 标识符

    总时间限制: 
    1000ms
     
    内存限制:
     
    65536kB
    描述

    给定一个不包含空白符的字符串,请判断是否是C语言合法的标识符号(注:题目保证这些字符串一定不是C语言的保留字)。

    C语言标识符要求:

    1. 非保留字;

    2. 只包含字母、数字及下划线(“_”)。

    3. 不以数字开头。

    输入
    一行,包含一个字符串,字符串中不包含任何空白字符,且长度不大于20。
    输出
    一行,如果它是C语言的合法标识符,则输出yes,否则输出no。
    样例输入
    RKPEGX9R;TWyYcp
    样例输出
    no

    思路:

      水题使我快乐;

    来,上代码:

    #include<cstdio>
    #include<string>
    #include<iostream>
    #include<algorithm>
    
    using namespace std;
    
    int len;
    
    string word;
    
    int main()
    {
        cin>>word;
        len=word.length();
        if(word[0]<='9'&&word[0]>='0')
        {
            printf("no
    ");
            return 0;
        }
        for(int i=0;i<len;i++)
        {
            if((word[i]<'0'||word[i]>'9')&&(word[i]>'z'||word[i]<'a')&&(word[i]>'Z'||word[i]<'A')&&word[i]!='_')
            {
                printf("no
    ");
                return 0;
            }
        }
        printf("yes
    ");
        return 0;
    }
  • 相关阅读:
    Xcode-调试断点不能停在代码区终极解决方案
    iOS-修改Status Bar
    iOS-appStore发布流程
    iOS-Debug调试
    iOS-项目搭建
    iOS-UIButton-设置button标题和图片位置
    iOS-布局-Masonry-优先级
    intent 传参数
    五大布局
    execute、executeQuery和executeUpdate之间的区别
  • 原文地址:https://www.cnblogs.com/IUUUUUUUskyyy/p/6104267.html
Copyright © 2011-2022 走看看