#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;if (a>b)swap(pointer_1,pointer_2);printf("min = %d,max = %d\n",b,a);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 关注
- 5396 浏览
添加回答
举报
0/150
提交
取消