CodeForces 8A - Train and Peter

来源:互联网 发布:中国交通事故数据统计 编辑:程序博客网 时间:2024/04/29 14:11
题目意思很明确。。。。。开始用string.find(),就是在第14个测试点wa,然后用了strstr();
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <algorithm>using namespace std;int main(){char str[100005],str1[100005],str2[100005];scanf("%s%s%s",str,str1,str2);int flag1,flag2;flag1=strstr(str,str1)&&strstr(strstr(str,str1)+strlen(str1),str2);reverse(str,str+strlen(str));flag2=strstr(str,str1)&&strstr(strstr(str,str1)+strlen(str1),str2);    if(flag1&&flag2)    cout<<"both\n";    else if(!flag1&&!flag2)    cout<<"fantasy\n";    else if(flag1)    cout<<"forward\n";    else     cout<<"backward\n";    return 0;}

0 0