Home > Back-end >  In vs2019 can work out the answer and submit has been a wrong answer, where is my fault? Big help ge
In vs2019 can work out the answer and submit has been a wrong answer, where is my fault? Big help ge

Time:12-02

19: displacement of string contains problems

Description

For a string, defines a cyclic shift operation: at the end of the first character of a string to move to form a new string,

Given two strings s1 and s2 and asked to determine whether one string is a string by several times after the cyclic shift of new substring of string, for example CDAA is new series produced by AABCD twice after displacement BCDAA substring, whereas the ABCD and ACBD cannot get by multiple shift one string is a new list of substrings,
Enter
A line containing two strings, separated by a single space between, string contains only letters and Numbers, length of not more than 30,
O
If a string is a string for several times by cyclic shift of the new string substring, the output is true, false, otherwise the output
The sample input

AABCD CDAA

Sample output

True


# include
# include
# include
using namespace std;
Int main ()
{
[35] char a, b [35];
cin> A. & gt;> b;
Int len1=strlen (a);
Int len2=strlen (b);
Int flag=0;

If (len1 & gt;=len2)
{
for (int i=0; i Char temp=a, [0].
For (int j=0; J & lt; Len1; J++) {
If (j==len1-1)
A [j]=temp;
The else
A [j]=a, a + 1 bonus to [j].
}
For (int m=0; M & lt; Len1; M++) {
If (b [0]==a [m])
{
For (int n=0; N & lt; Len2; N++ m++) {
If (b [n]=[m])
{
Flag=1;
continue;
}
The else
{
Flag=0;
break;
}
}
}
}
If (flag==1)
{
cout <"True";
return 0;
}
}
}
Else if (len1 & lt; Len2)
{
for (int i=0; i Char \ [0]=b;
For (int j=0; J & lt; Len1; J++) {
If (j==len1-1)
B [j]=temp;
The else
B=b [j] [j + 1);
}
For (int m=0; M & lt; Len1; M++) {
If (a [0]==b [m])
{
For (int n=0; N & lt; Len2; N++ m++) {
If (a=b [n] [m])
{
Flag=1;
continue;
}
The else
{
Flag=0;
break;
}
}
}
}
If (flag==1)
{
cout <"True";
return 0;
}
}
}
cout <"False".
return 0;
}

CodePudding user response:

You enter a few more examples, certainly not

CodePudding user response:

 
#include
#include

Int main ()
{
STD: : string a, b;
Int p;

While (STD: : cin & gt;> A. & gt;> B,! A.e mpty () | |! STD: : cin. Eof ())
{
For (p=0, a +=a; P & lt; A.s considering (); P++)
If (a.f ind (b, p)!=STD: : string: : npos)
{
STD: : cout & lt; <"True" & lt; break;
}
If (p==a.s considering ()) STD: : cout & lt; <"False" & lt; A.c Lear ();
}

return 0;
}

  • Related