题目内容
程序填空题:编写方法,按升序显示三个数。编写测试程序,提示用户输入三个整数,调用方法以升序显示它们。public class Sort {public static void main(String[] args) {Scanner scan=new Scanner(System.in);System.out.print("请输入三个整数:");int num1=scan.nextInt();int num2=scan.nextInt();int num3=scan.nextInt();System.out.printf("%d,%d,%d\n",num1,num2,num3);displaySortedNum(num1,num2,num3);}public static void displaySortedNum(int num1, int num2, int num3) {if(num1>num2){int temp=num1;num1=num2;num2=temp;}if(num1>num3){int temp=num1;num1=num3;num3=temp;}if(1){int temp=2;=num2;num2=temp;}System.out.printf("%d,%d,%d\n",num1,num2,num3);}}
查看答案
搜索结果不匹配?点我反馈