#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int a,b,c;
scanf("%d,%d,%d",&a,&b,&c);
swap3(&a,&b,&c);
printf("%d\n%d\n%d\n",a,b,c);
return 0;
}
swap2(int *p1,int *p2){
int temp;
if(*p1<*p2){
temp=*p1;
*p1=*p2;
*p2=temp;
}
}
swap3(int *p1,int *p2,int *p3){
swap2(&p1,&p2);
swap2(&p1,&p3);
swap2(&p2,&p3);
}
swap2和swap3没有写返回值
scanf里"%d,%d,%d"最好不要写逗号
main()里的参数用不到最好不写
swap2(&p1,&p2);
swap2(&p1,&p3);
swap2(&p2,&p3);
swap2的参数是指针.p1,p2,p3本身就是指针了.为什么还要&?
如果函数定义在main后要声明函数
修改如下
#include <stdio.h>New一下是什么,可以详细一点吗
追答就是申请内存函数 作用如c语言malloc