18: Verify the substring, 18 Verification

Source: Internet
Author: User

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 } 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.