• Alex and broken contest CodeForces


    /*
        Name:
        Copyright:
        Author:
        Date: 2018/5/2 10:45:16
        Description:
        要求出现一个朋友的名字,仅一次 
    */
    #include <iostream>
    #include <cstdio>
    #include <string> 
    using namespace std;
    int main()
    {
    //    freopen("in.txt", "r", stdin);
        string fname1 = "Danil";
        string fname2 = "Olya";
        string fname3 = "Slava";
        string fname4 = "Nikita";
        string fname5 = "Ann";
        string str;
        while (cin>>str) {
            int flag = 0;
            if (str.find(fname1) != -1) {
                int pos = 0;
                string tmp = str;
                while ((pos = tmp.find(fname1)) != -1) {
                    flag ++;
                    tmp = tmp.substr(pos + 1);
                    if (flag >= 2) break;
                }
            } 
            if (str.find(fname2) != -1) {
                int pos = 0;
                string tmp = str;
                while ((pos = tmp.find(fname2)) != -1) {
                    flag ++;
                    tmp = tmp.substr(pos + 1);
                    if (flag >= 2) break;
                }
            } 
            if (str.find(fname3) != -1) {
                int pos = 0;
                string tmp = str;
                while ((pos = tmp.find(fname3)) != -1) {
                    flag ++;
                    tmp = tmp.substr(pos + 1);
                    if (flag >= 2) break;
                }
            } 
            if (str.find(fname4) != -1) {
                int pos = 0;
                string tmp = str;
                while ((pos = tmp.find(fname4)) != -1) {
                    flag ++;
                    tmp = tmp.substr(pos + 1);
                    if (flag >= 2) break;
                }
            } 
            if (str.find(fname5) != -1) {
                int pos = 0;
                string tmp = str;
                while ((pos = tmp.find(fname5)) != -1) {
                    flag ++;
                    tmp = tmp.substr(pos + 1);
                    if (flag >= 2) break;
                }
            } 
            if (flag == 1) {
                cout<<"YES"<<endl;
            } else {
                cout<<"NO"<<endl;
            }
        }
        return 0;
    }
  • 相关阅读:
    ci上传图片
    Mac下使用svn命令
    linux 下svn忽略文件
    thinkphp5 隐藏入口和支持pathinfo
    ci tp重定向
    php命名空间
    thinkphp5学习记录一
    Mac下安装homebrew
    使用iTerm2快捷连接SSH
    摄影基础
  • 原文地址:https://www.cnblogs.com/slothrbk/p/8979271.html
Copyright © 2020-2023  润新知