如何利用嵌套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
提交
取消