未来_我来
因为渴望改变,所以必须努力

题目:输入3个数a,b,c,按大小顺序输出

 1 package com.li.FiftyAlgorthm;
 2 
 3 import java.util.Scanner;
 4 
 5 /**
 6  * 题目:输入3个数a,b,c,按大小顺序输出。
 7  * @author yejin
 8  */
 9 public class Compare {
10     public static void main(String[] args) {
11         Scanner s = new Scanner(System.in);
12         int a = s.nextInt();
13         int b = s.nextInt();
14         int c = s.nextInt();
15 
16         if (a < b) {
17             int t = a;
18             a = b;
19             b = t;
20         }
21 
22         if (a < c) {
23             int t = a;
24             a = c;
25             c = t;
26         }
27 
28         if (b < c) {
29             int t = b;
30             b = c;
31             c = t;
32         }
33 
34         System.out.println("从大到小的顺序输出:");
35         System.out.println(a + " " + b + " " + c);
36     }
37 }

 

posted on 2017-07-09 22:27  未来_我来  阅读(1630)  评论(0编辑  收藏  举报

2 3
4