java中输入3个数,从大到小的输出。。。。
总结:我暂时不能理解,C语言时讲过,java里就不理解了
package com.a; import java.sql.Date; import java.util.Scanner; //输入三个数,按从小到达的顺序输出 public class Test { public static void main(String[] args) { Scanner c = new Scanner(System.in); System.out.println("请输入3个数"); int a = c.nextInt(); int b = c.nextInt(); int s = c.nextInt(); System.out.println(a + "," + b + "," + s); int temp; if (a < b) {//b此时是temp。a是b/ temp = a; a = b; b = temp; } if (a < s) { temp = a; a = s; s = temp; } if (b < s) { temp = b; b = s; s = temp; } System.out.println("结果:" + a + ">" + b + ">" + s); } }