HDU 2205 亲和串

来源:互联网 发布:android编程实战 pdf 编辑:程序博客网 时间:2024/06/16 14:23

链接 : http://acm.hdu.edu.cn/showproblem.php?pid=2205


只要把第一个字符串复制两遍,在其中找字串2的字串即可,水过


#include <iostream>#include <cstring>#define MAX 100001using namespace std;char str1[MAX],str2[MAX],str3[MAX*2];int main(){    while(cin>>str1>>str2)    {        strcpy(str3,str1);        strcat(str3,str1);        strstr(str3,str2) ? cout<<"yes"<<endl : cout<<"no"<<endl;    }    return 0;}


0 0