输入3个数a,b,c,按大小顺序输出
发布时间:2022-09-30 11:39:14 518 相关标签: # java# java
题目:输入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
文章来源: https://blog.51cto.com/u_11624854/5640864
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报