c语言如何编程使三个数字从小到大输出
答案:2 悬赏:60
解决时间 2021-02-07 04:16
- 提问者网友:时间却是纷扰
- 2021-02-07 00:01
c语言如何编程使三个数字从小到大输出
最佳答案
- 二级知识专家网友:偏爱自由
- 2021-02-07 00:43
#include
int main()
{
int i,j,m;
double temp;
double a[3];
for(m=0;m<3;m++) //输入三个数
{
scanf("%lf",&a[m]);
}
for(i=0;i<3;i++) //完成排序
{
for(j=i;j<3;j++)
{
if(a[j]{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
printf("%lf\t",a[i]);//打印结果
}
printf("\n");
return 0;
}
int main()
{
int i,j,m;
double temp;
double a[3];
for(m=0;m<3;m++) //输入三个数
{
scanf("%lf",&a[m]);
}
for(i=0;i<3;i++) //完成排序
{
for(j=i;j<3;j++)
{
if(a[j]{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
printf("%lf\t",a[i]);//打印结果
}
printf("\n");
return 0;
}
全部回答
- 1楼网友:许你一世温柔
- 2021-02-07 01:35
#include <stdlib.h>#include <stdio.h>int main() { int a, b, c; printf("请输入三个数:"); scanf_s("%d%d%d", &a, &b, &c); int temp; if (a > b) { temp = a; a = b; b = temp; } if (b > c) { temp = c; c = b; b = temp; } if (a > b) { temp = a; a = b; b = temp; } printf("%d < %d < %d
", a, b, c); system("pause"); return 0;}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯