Home > Back-end >  Result is right, but always said after running period of mistake, I really don't know where is
Result is right, but always said after running period of mistake, I really don't know where is

Time:04-11

CodePudding user response:

At first glance, the input should be changed like this:
 while ((a) [j]=getchar ())! )='\ n' {
j++;
}

CodePudding user response:

Modified as follows, for your reference:
 # include 

Int main ()
{
Int I, j, n, m;
Char a [1024], w;
J=0;
The scanf (" % d ", & amp; N);
getchar();
While ((a) [j]=getchar ())! )='\ n' {
j++;
}
for(i=1; i<=n; I++) {
For (m=1, j w=a, [m]. M> 0; M -) {
A [m]=a [m - 1);
}
A [m]=w;
}
for(i=0; iPrintf (" % c ", a [I]);
}

return 0;
}

CodePudding user response:

Fixed upstairs, line 22 increase printf (" \ n "); :
 # include 

Int main ()
{
Int I, j, n, m;
Char a [1024], w;
J=0;
The scanf (" % d ", & amp; N);
getchar();
While ((a) [j]=getchar ())! )='\ n' {
j++;
}
for(i=1; i<=n; I++) {
For (m=1, j w=a, [m]. M> 0; M -) {
A [m]=a [m - 1);
}
A [m]=w;
}
for(i=0; iPrintf (" % c ", a [I]);
}
printf("\n");

return 0;
}

CodePudding user response:

reference QZJHJXJ reply: 3/f
corrections upstairs, line 22 increase printf (" \ n "); :
 # include 

Int main ()
{
Int I, j, n, m;
Char a [1024], w;
J=0;
The scanf (" % d ", & amp; N);
getchar();
While ((a) [j]=getchar ())! )='\ n' {
j++;
}
for(i=1; i<=n; I++) {
For (m=1, j w=a, [m]. M> 0; M -) {
A [m]=a [m - 1);
}
A [m]=w;
}
for(i=0; iPrintf (" % c ", a [I]);
}
printf("\n");

return 0;
}

Well, if not, good mentality collapsed, difficult

CodePudding user response:

What kind of error?

CodePudding user response:

Try to change this:
 # include 
#include
Int main ()
{
Int I, len, n, m;
Char a [1001], w;
The scanf (" % d ", & amp; N);
getchar();
Gets (a);
Len=strlen (a);
for(i=1; i<=n; I++) {
For (m=, len - 1 w=a, [m]. M> 0; M -) {
A [m]=a [m - 1);
}
A [m]=w;
}
Puts (a);

return 0;
}

CodePudding user response:

 
# include & lt; stdio.h>
#include
Int main (int arg c, char * argv [])
{
Int I, len, n, k;
Char STR [1001], [1001] s.
{

The scanf (" % d % s ", & amp; N, STR);
Len=strlen (STR);
K=n % len;//& gt;=the movement of the len are repeated
/* subject required is a circular movement, if the string end to end, is the starting point to the location of the mobile, as a string, before and after boundary exchange can be realized for k */
Strncpy (s, STR + len - k, k);
Strncpy (s + k, STR, len - k);
S [len]='\ 0';
Printf (" % s \ n ", s);
}
return 0 ;
}
  • Related