为什么这道题用cin可以通过,换成getline就不行了呢?代码如下:
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1, s2;
cin >> s1 >> s2;
if (s1.find(s2)!=s1.npos) cout << s2 << " is substring of " << s1 << endl;
else if (s2.find(s1)!=s2.npos) cout << s1 << " is substring of " << s2 << endl;
else cout << "No substring" << endl;
return 0;
}