C语言作业 已知a,b,c,d四个数,按从小到大的顺序输出用if语句
2个回答
展开全部
#include<stdio.h>
int main()
{
int a, b, c, d, tmp;
if(a < b){
tmp = a, a = b, b =tmp;
}
if(a < c){
tmp = a, a = c, c =tmp;
}
if(a < d){
tmp = a, a = d, d =tmp;
}
if(b < c){
tmp = b, b = c, c =tmp;
}
if(b < d){
tmp = b, b = d, d =tmp;
}
if(c < d){
tmp = c, c = d, d =tmp;
}
printf("按照从小到大:%d %d %d %d", a, b, c, d);
return 0;
}
展开全部
1234567891011121314151617181920212223242526#include<stdio.h> int main(){ int a, b, c, d, tmp; if(a < b){ tmp = a, a = b, b =tmp; } if(a < c){ tmp = a, a = c, c =tmp; } if(a < d){ tmp = a, a = d, d =tmp; } if(b < c){ tmp = b, b = c, c =tmp; } if(b < d){ tmp = b, b = d, d =tmp; } if(c < d){ tmp = c, c = d, d =tmp; } printf("按照从小到大:%d %d %d %d", a, b, c, d); return 0;}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询