为甚么交换不成?
程序代码:
#include<stdio.h> void swap(int *p1, int *p2) { int *t; t = p1; p1 = p2; p2 = t; } int main() { void swap(int *p1, int *p2); int a, b; int *x1 = &a, *x2 = &b; scanf_s("%d%d", &a, &b); if (a < b) swap(x1, x2); printf("%d %d\n", *x1, *x2); return 0; }