cf 8a Train and Peter

来源:互联网 发布:杭州淘宝培训学校 编辑:程序博客网 时间:2024/05/16 02:00
#include <iostream>#include <cstdio>#include <algorithm>using namespace std;int main(){    string s,s1,s2;    bool f1=false,f2=false;    cin>>s>>s1>>s2;    int a,b;    a=s.find(s1);    if(a!=std::string::npos)    {        b=s.find(s2,a+s1.length());        if(b!=std::string::npos)            f1=true;    }    string ss="";    for(int i=s.length()-1;i>=0;i--)        ss+=s[i];    a=ss.find(s1);    if(a!=std::string::npos)    {        b=ss.find(s2,a+s1.length());        if(b!=std::string::npos)            f2=true;    }    if(f1&&f2)        printf("both\n");    else if(f1)        printf("forward\n");    else if(f2)        printf("backward\n");    else        printf("fantasy\n");    return 0;}

0 0
原创粉丝点击