zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    numpy常用函数
    python 语法学习
    python学习:字典
    python 字符串使用
    k-近邻算法
    Numpy函数库
    机器学习初体验
    Xcode8 + iOS10Beta 权限问题崩溃的解决方法
    苹果设备全攻略
    使用 Xcode 代码块
  • 原文地址:https://www.cnblogs.com/langyao/p/8979271.html
Copyright © 2011-2022 走看看