形参无法改变,你可以直接在子函数输出
程序代码:
#include<stdio.h> int main() { int a, b; void exchange(int x, int y); printf("请输入两个整数:"); scanf("%d %d", &a, &b); if (a>b)exchange(a, b);//满足a<b printf("按从小到大的顺序输出:%d %d\n", a, b); return 0; } void exchange(int x, int y) { int z; z = y; y = x; x = z;// x=z printf("按从小到大的顺序输出:%d %d\n", x, y); }