Home > Back-end >  Doing the topic, the topic has been don't understand I very concerned must make sense of it, a
Doing the topic, the topic has been don't understand I very concerned must make sense of it, a

Time:10-07

{
Char x [80]="AB", [80] y="LMNP";
Int n=0;
Strcat (x, y);
While (x [n++]!='\ 0')
[n] y=x [n].
Puts (y); }
A, LBB, ABLMNPC, ABD, LBLMNP
To ask, the answer is LBLMNP, but I can't understand the first L come from,

CodePudding user response:

While (n++) this sentence, judge 0, then become 1 + +, after entering the first sentence is [1] y=x [n], so y [0] remain the same

CodePudding user response:

The problem here
 while (x [n++]!='\ 0') 

Cycle for the first time, n=0, since is a suffix, so the judgment on whether the x [0] is equal to '\ 0', the n value into 1, then execute the while loop body at this time, n=1
 [n] y=x [n]. 

that is [1] y=x [1], [0] y previous value has not been x [0] cover ,
Change the code to the
 while (x [n].='\ 0') 
{
[n] y=x [n].
n++;
}

Can realize to complete modification of y,

CodePudding user response:

refer to the second floor MianHou response:
problem here
 while (x [n++]!='\ 0') 

Cycle for the first time, n=0, since is a suffix, so the judgment on whether the x [0] is equal to '\ 0', the n value into 1, then execute the while loop body at this time, n=1
 [n] y=x [n]. 

that is [1] y=x [1], [0] y previous value has not been x [0] cover ,
Change the code to the
 while (x [n].='\ 0') 
{
[n] y=x [n].
n++;
}

Can realize to complete modification of y,

Thank you for your duck duck

CodePudding user response:

reference 1st floor ggglivw response:
while (n++) this sentence, judge 0, then become 1 + +, after entering the first sentence is [1] y=x [n], so y [0] intact

Thank you do ~
  • Related