18: Verify the substring, 18 Verification
18: Verify the substring
- View
- Submit
- Statistics
- Question
-
Total time limit:
-
1000 ms
-
Memory limit:
-
65536kB
-
Description
-
Enter two strings to verify whether one is a substring of the other.
-
Input
-
Enter two strings, each of which occupies one line. The length cannot exceed 200 and no space is included.
-
Output
-
If the first string s1 is a child string of the second string s2, the output (s1) is substring of (s2)
Otherwise, if the second string s2 is the Child string of the first string s1, the output (s2) is substring of (s1)
Otherwise, No substring is output.
-
Sample Input
-
abcdddncabca
-
Sample output
-
abc is substring of dddncabca
-
Source
-
JerryCircle [Java programming]
-
1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 string a,b,c; 5 int main() 6 { 7 cin>>a>>b; 8 if(a.find(b)!=-1) 9 cout<<b<<" is substring of "<<a;10 else if(b.find(a)!=-1)11 cout<<a<<" is substring of "<<b;12 else cout<<"No substring";13 return 0;14 }