#include<stdio.h>
int main()
{
int *p1, *p2, *p, a, b;
scanf("%d %d", &a, &b);
p1 = &a;
p2 = &b;
if (a<b){
p = p1;
p1 = p2;
p2 = p;
}
printf("a = %d, b= %d\n", a, b);
printf("max=%d, min=%d\n", *p1, *p2);
return 0;
}
#include<stdio.h>
int main(){
void swap(int * p1, int *p2);
int a, b;
int *point_1, *point_2;
printf("Please input two numbers:\n");
scanf("%d %d", &a, &b);
point_1 = &a;
point_2 = &b;
printf("a=%d, b=%d\n", a, b);
printf("point1===%d, point2===%d\n",point_1,point_2);
if (a<b){
swap(point_1, point_2);
}
printf("After exchanged:\n");
printf("a=%d, b=%d\n", a, b);
return 0;
}
void swap(int *p1, int *p2)
{
int tmp;
printf("function start: p1===%d, p2===%d\n",p1, p2);
printf("function start: *p1===%d, *p2===%d\n",*p1, *p2);
printf("tmp=%d\n",tmp);
tmp = *p1;
printf("tmp=%d\n",tmp);
*p1 = *p2;
*p2 = tmp;
printf("function end: p1===%d, p2===%d\n",p1, p2);
printf("function end: *p1===%d, *p2===%d\n",*p1, *p2);
}