zoukankan      html  css  js  c++  java
  • codevs 爱改名的小融

    都是三道水题 但我很难理解的是 string 能过

    char 就WA 

    2967 

    题目描述 Description

    Wikioi上有个人叫小融,他喜欢改名。

    他的名字都是英文,只要按顺序出现R,K,Y三个字母,就是他的名字。

    给你N个名字,请你一一判断是不是小融。

    输入描述 Input Description

    N

    N行,名字(全大写)

    输出描述 Output Description

    N行,每行YES或NO(大写)

    样例输入 Sample Input

    3

    RKY

    RAINKY

    RINKEMENT

    样例输出 Sample Output

    YES

    YES

    NO

    数据范围及提示 Data Size & Hint

    N<=10,字符串长度<=50.

    点击传送

    代码 

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <string>
    
    using namespace std;
    
    int N;
    string s;
    int main()
    {
        cin>>N;
        while(N--)
        {
            bool f1=false,f2=false,f3=false;
            cin>>s;
            int l=s.length();
            for(int i=0;i<l;++i)
            {
                if(s[i]=='R'&&!f2&&!f3)
                f1=1;
                else if(s[i]=='K'&&f1&&!f3)
                f2=1;
                else if(s[i]=='Y'&&f1&&f2)
                f3=1;
            }
            if(f1&&f2&&f3)
            puts("YES");
            else puts("NO");
        }
    }

    -------------------------------------------华丽的分割线---------------------------------------------------

    3149

    题目描述 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 <iostream>
    #include <cstring>
    #include <cstdio>
    #include <string>
    
    using namespace std;
    
    int N;
    string s;
    int main()
    {
        cin>>N;
        char ch=getchar();
        while(N--)
        {
            bool f=false;
            cin>>s;
            int l=s.length() ;
            for(int i=0;i<l;++i)
            {
                if(((s[i]>='A'&&s[i]<='Z')||(s[i]>='a'&&s[i]<='z')));
                else 
                {
                    cout<<"NO"<<endl;
                    f=true;
                    break;
                }
            }
            if(!f)
            cout<<"YES"<<endl;
        }
    }

    -------------------------------------------华丽的分割线---------------------------------------------------

    3156

    题目描述 Description

    Wikioi上有个人叫小融,他喜欢改名。
    现在他的要求变了,只要是英文字母就是他的名字。
    先给你N个名字,请你输出正确名字的个数及编号。
    本题还加强了测试数据

    输入描述 Input Description

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

    输出描述 Output Description

    第一行:个数
    第二行:编号

    样例输入 Sample Input

    3
    &6*14315
    Rinkement
    micsloox

    样例输出 Sample Output

    2
    2 3 

    数据范围及提示 Data Size & Hint

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

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <queue>
    
    using namespace std;
    
    queue<int>q;
    int N;
    string s;
    int main()
    {
        cin>>N;
        char ch=getchar();
        int h=0;
        for(int i=1;i<=N;++i)
        {
            bool f=false;
            cin>>s;
            int l=s.length() ;
            for(int j=0;j<l;++j)
            {
                if(((s[j]>='A'&&s[j]<='Z')||(s[j]>='a'&&s[j]<='z')));
                else 
                {
                    f=true;
                    break;
                }
            }
            if(!f)
            {
                q.push(i); 
                h++;
            }
        }
        cout<<h<<endl;
        while(!q.empty() )
        {
            cout<<q.front()<<" ";
            q.pop();
        }
    }
    我们都在命运之湖上荡舟划桨,波浪起伏着而我们无法逃脱孤航。但是假使我们迷失了方向,波浪将指引我们穿越另一天的曙光。
  • 相关阅读:
    Problem with the SSL CA cert (path? access rights?)
    亚马逊ec2使用nginx运行tp5报502
    MySQL 5.7 聚合函数列需要先group by
    Apache服务器HTTPS未完全正确配置的处理
    《将博客搬至CSDN》
    pytorch 8 CNN 卷积神经网络
    pytorch 7 optimizer 优化器 加速训练
    pytorch 6 batch_train 批训练
    pytorch 7 save_reload 保存和提取神经网络
    pytorch 6 build_nn_quickly 快速搭建神经网络
  • 原文地址:https://www.cnblogs.com/ruojisun/p/6379726.html
Copyright © 2011-2022 走看看