如何利用嵌套if来实现3个数从小到大的排序
1 回答
已采纳
OneKi
TA贡献75条经验 获得超45个赞
if(a>b){ if(c>a){ System.out.println(b+","+a+","+c); }else if(c<b){ System.out.println(c+","+b+","+a); }else{ System.out.println(b+","+c+","+a); } }else{ if(c<a){ System.out.println(c+","+a+","+b); }else if(c>b){ System.out.println(a+","+b+","+c); }else{ System.out.println(a+","+c+","+b); } }
添加回答
举报
0/150
提交
取消