#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 ,bpointer_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;}
- 1 回答
- 0 关注
- 1952 浏览
添加回答
举报
0/150
提交
取消