|
|
发表于 2011-12-6 20:27:19
|
显示全部楼层
本帖最后由 秋舞斜阳 于 2011-12-6 20:30 编辑
- #include<stdio.h>
- void main()
- {
- void exchange(int *q1,int *q2,int *q3);
- int a, b, c, *p1, *p2, *p3;
- scanf("%d, %d, %d", &a, &b, &c);
- p1 = &a;
- p2 = &b;
- p3 = &c;
- exchange(p1, p2, p3);
- printf("\n%d, %d, %d\n", a, b, c);
- }
- void exchange(int *q1,int *q2,int *q3) //这里的void打成viod了;我也出现过这种情况。
- {
- void swap(int *pt1,int *pt2);
- if(*q1 < *q2) swap(q1, q2);
- if(*q1 < *q3) swap(q1, q3);
- if(*q2 < *q3) swap(q2, q3);
- }
- void swap(int *pt1,int *pt2)
- {
- int temp;
- temp = *pt1;
- *pt1 = *pt2;
- *pt2 = temp;
- }
复制代码 |
|