#include <stdio.h>
int main()
{//交换地址
void swap(int *p1,int *p2); //申明swap函数
int a,b; //定义初始变量
int *pointer_1,*pointer_2; //定义两个指针变量
printf("please enter a and b:\n");
scanf("%d,%d",&a,&b); //将输入的两个常数赋值给初试变量a ,b
pointer_1 = &a;
pointer_2 = &b;
printf("pointer_1 = %d,pointer_2 = %d\n",*pointer_1,*pointer_2);
printf("a = %d,b = %d\n",a,b);
swap(pointer_1,pointer_2);
/*int *p;
p = pointer_1;
pointer_1 = pointer_2;
pointer_2 = p;*/
printf("max = %d,min = %d",*pointer_1,*pointer_2);
return 0;
}
void swap(int *p1,int *p2)
{
int *p;
p = p1;
p1 =p2;
p2 = p;
}
宾丶高