1 solutions
-
1
#include #include
using namespace std;
string s,t;
bool check(string s,string t){ //判定t是否是s的子串 for (int i=0;i<s.length();i++){ bool flag = true; for (int j=0;j<t.length();j++) if (s[i+j] != t[j]) flag = false; if (flag) return 1; } return 0; }
int main(){ cin >> s >> t; if (s.length() < t.length()) swap(s,t); //让s一定是较长的串
if (check(s,t)) cout << t << " is substring of " << s; else cout << "No substring";
}
- 1
Information
- ID
- 6933
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 1
- Tags
- # Submissions
- 51
- Accepted
- 39
- Uploaded By