三个数字从小到大排列#includemain(){ int a,b,c;void exchange(int m,int n);scanf("%d%d%d",&a,&b,&c);if (a>b){exchange(a,b);}else ;if (a>c)exchange(a,c);else ;if (b>c)exchange(b,c);printf("%d %d %d",a,b,c);}void exchange(int m,int n){ int d;d=
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/16 15:47:13
三个数字从小到大排列#includemain(){ int a,b,c;void exchange(int m,int n);scanf("%d%d%d",&a,&b,&c);if (a>b){exchange(a,b);}else ;if (a>c)exchange(a,c);else ;if (b>c)exchange(b,c);printf("%d %d %d",a,b,c);}void exchange(int m,int n){ int d;d=
三个数字从小到大排列
#include
main()
{
int a,b,c;
void exchange(int m,int n);
scanf("%d%d%d",&a,&b,&c);
if (a>b)
{exchange(a,b);}
else ;
if (a>c)
exchange(a,c);
else ;
if (b>c)
exchange(b,c);
printf("%d %d %d",a,b,c);
}
void exchange(int m,int n)
{ int d;
d=m;
m=n;
n=d;
}
通过了编译,但是输入5 1 2,输出还是5 1 2,根本没有从小到大排列.
三个数字从小到大排列#includemain(){ int a,b,c;void exchange(int m,int n);scanf("%d%d%d",&a,&b,&c);if (a>b){exchange(a,b);}else ;if (a>c)exchange(a,c);else ;if (b>c)exchange(b,c);printf("%d %d %d",a,b,c);}void exchange(int m,int n){ int d;d=
冒泡排序不会吗?搞那么复杂