c程序设计第四版谭浩强
输入4个整数 要求按照从小到大的顺序输出。(c程序设计第四版谭浩强课后答案)
以下是此题的【c源程序】,需要【c++源代码】的请点击进入
#include <stdio.h>
int main()
{int t,a,b,c,d;
printf("请输入四个数:");
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
printf("a=%d,b=%d,c=%d,d=%d\n",a,b,c,d);
if (a>b)
{ t=a;a=b;b=t;}
if (a>c)
{ t=a;a=c;c=t;}
if (a>d)
{ t=a;a=d;d=t;}
if (b>c)
{ t=b;b=c;c=t;}
if (b>d)
{ t=b;b=d;d=t;}
if (c>d)
{ t=c;c=d;d=t;}
printf("排序结果如下: \n");
printf("%d %d %d %d \n" ,a,b,c,d);
return 0;
}
本文链接:http://www.wb98.com/c/post/tanhaoqiang_4.11.html
本站文章搜索: