这个题很水(我做半天
用字符串函数find就可以
找不到返回-1;或 string::npos
上代码:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
using namespace std;
string s1,s2;
int main(){
cin>>s1>>s2;
if((s2.find(s1)!=-1 && s1.find(s2)==-1)){
cout<<s1<<" is substring of "<<s2;
}
else if(s1.find(s2)!=-1 && s2.find(s1)==-1){
cout<<s2<<" is substring of "<<s1;
}
else if(s1.find(s2)==-1 && s2.find(s1)==-1){
cout<<"No substring";
}
return 0;
}