Home > Back-end >  Solving where wrong..
Solving where wrong..

Time:12-04

#include
Int main ()
{
Void swap (int * q1, q2 int * and an int * q3);
Int a=1, b=2, c=3;
P1, int * * p2, p3;
//printf (" both please enter 3 Numbers: ");
//scanf_s (" % d % d % d ", & amp; A, & amp; B, & amp; C);
P1=& amp; a;
The p2=& amp; b;
P3=& amp; b;
Swap (p1, p2, p3);
Printf (" % d % d % d ", a, b, c);
return 0;
}
Void swap (int * q1, q2 int * and an int * q3)
{
Void exchage (int * c1 and c2 int *);
If (* q1 & lt; * q2) exchage (q1, q2);
If (* q1 & lt; * q3) exchage (q1, q3);
If (* q2 & lt; * q3) exchage (q2, q3);
}
Void exchage (int * c1, c2) int *
{
Int t;
T=* c1;
* c1=* c2;
* c2=t;
}
Debugging results of 2 1 3; The value of the pointer variable in the main function change?? A little confused

CodePudding user response:

What is this confusion

CodePudding user response:

reference 1st floor qiu_shaofeng response:
what is this wonder?

According to the size of the output sequence

CodePudding user response:

reference 1st floor qiu_shaofeng response:
what is this wonder?

According to the size of the output sequence to know which to wrong sorry didn't describe complete

CodePudding user response:

reference 1st floor qiu_shaofeng response:
what is this wonder?

According to the size of the output sequence to know which to wrong sorry didn't describe complete

CodePudding user response:

P1=& amp; a;
The p2=& amp; b;
P3=& amp; b;
And p3 didn't you pick up c address!

CodePudding user response:

P3 to take c address, I here in the building code to run result is 3 2 1

CodePudding user response:

reference 5 floor Army_Adviser_ reply:
exchage function to write the wrong
Void exchage (int * c1, c2) int *
{
Int * t=NULL;
T=c1;
C1=c2.
C2=t;
}

No give p3 c address assignment of the building Lord,
If according to your modifications, the output is the result of the 1, 2, 3 order did not change, suggest that test

CodePudding user response:

P1=& amp; a;
The p2=& amp; b;
p3=& amp; b;

Is the place not to c above, how to test just now is right, the output of 3 2 1
  • Related