Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language array assignment problem
C language array assignment problem

You think the assignment is wrong because you take it for granted! In fact, it’s not that the assignment is wrong, but that your logic is wrong! Look at your code:

p[n][0]=zero; /************/

p[n][1 ]=zigzag[i]; /******************/

n++;

zero=0;

< p>printf("%d\t%d\n",p[n][0],p[n][1]);

When n=0, you give p[ 0][0] and p[0][1] are assigned, then n++, at this time n=1, right? Then the print statement becomes: printf("%d\t%d\n",p[1][0],p[1][1]), do you understand? So the n++ sentence should be moved after the printf statement! There is also a problem with the boundary value of your for statement. I won’t tell you yet. You should change the position of n++ first and then run it. If you don’t know what the problem is with for after changing it, ask me again