201409-3
The problem description gives a string and multiline text in which the lines that appear in the string are found. Your program also needs to support case sensitive options: When an option is on, the uppercase and lowercase letters of the same letter are treated as different characters; When the item is turned off, the uppercase and lowercase letters of the same letter are considered to be the same characters. Input format the first line of input contains a string s, composed of uppercase and lowercase English letters. The second line contains a number that represents the case-sensitive option, when the number is 0, the case is not sensitive, and when the number is 1, it is case sensitive. The third line contains an integer n that represents the number of lines of the given text. Next n rows, each line contains a string, and the string consists of uppercase and lowercase letters, without spaces and other characters. The output format outputs multiple lines, each containing a string, followed by the rows that contain the string s in the order in which they appear. Example input Hello15helloworldhihihellohihigrepisagreattoolhellohelloisnothello sample output Helloworldhihihellohihihelloisnothello Sample description In the example above, the fourth string, although also a hello, is not case-sensitive. If you change the second line of input to 0, the fourth string should be output. Evaluation Case size and Convention 1<=n<=100, each string length does not exceed 100. Source code: #include <iostream>
#include <string>
using namespace Std;
int main ()
{
String a,b[101],c[101];
int i,j,n,f;
cin>>a;
cin>>f>>n;
for (i=0;i<n;i++)
{
cin>>b[i];
C[i]=b[i]; It is best to assign values directly between strings, which is not easy to error
}
if (f==0)
{
for (i=0;a[i]!= ' n '; i++)
{
if (a[i]>= ' a ' &&a[i]<= ' Z ')
a[i]=a[i]+32;
}
for (i=0;i<n;i++)
{
for (j=0;b[i][j]!= ' n '; j + +)
{
if (b[i][j]>= ' A ' &&b[i][j]<= ' Z ')
c[i][j]=b[i][j]+32;
Else did not assign a value to the C array before entering the value of b[i], but instead of assigning it here, only 50 points, the reason is not very clear
C[I][J]=B[I][J];
}
}
for (i=0;i<n;i++)
{
For (J=0;j<=b[i].length ()-a.length (); j + +)
if (C[i].substr (J,a.length ()) ==a)
{
cout<<b[i]<<endl;
Break
}
}
}
Else
{
for (i=0;i<n;i++)
{
For (J=0;j<=b[i].length ()-a.length (); j + +)
if (B[i].substr (J,a.length ()) ==a)
{
cout<<b[i]<<endl;
Break
}
}
}
return 0;
}
The string match of the CCF real problem