i 绝望

依然

Miss Lang

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);
	}

}

  

posted on 2013-11-01 07:18  juewang  阅读(2251)  评论(0编辑  收藏  举报

绝望依然

Miss Lang