Problem Description:
Very simple, to determine whether a given string appears in the target string. Partition case-insensitive and case-sensitive two cases.
csp Features:
The third question is generally csp string handling, c ++ string class Although difficult to use, but the master of words when the test might be able to save a lot of time.
Code:
. 1 #include <the iostream> 2 #include <algorithm> . 3 #include < string > . 4 // use c ++ string class of transform algorithm and function . 5 the using namespace STD; . 6 . 7 int main () . 8 { . 9 int In Flag; 10 int n-; . 11 int FIN; 12 is String STR, TEMP; 13 is String S; 14 CIN >> STR; 15 CIN >> >> In Flag n-; 16 IF (In Flag) . 17 { 18 while(n--) 19 { 20 cin>>s; 21 if(s.find(str)!=string::npos) 22 cout<<s<<endl; 23 } 24 } 25 else //关大小写敏感 26 { 27 transform(str.begin(),str.end(),str.begin(),::tolower); 28 while(n--) 29 { 30 cin>>s; 31 temp = s;// Note that the results need to be saved before conversion case 32 // first case when s is not saved before the conversion, only half of the points 33 is Transform (s.begin (), s.end (), s .begin (), :: tolower); 34 is IF ! (s.find (STR) = String :: NPoS) 35 COUT TEMP << << endl; 36 } 37 [ } 38 is return 0 ; 39 }