题目:
输入3个数a,b,c,按大小顺序输出。
代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import java.util.scanner;
public class lianxi34 {
public static void main(string[] args) {
scanner s = new scanner(system.in);
system.out.println( "请输入3个整数:" );
int a = s.nextint();
int b = s.nextint();
int c = s.nextint();
if (a < b) {
int t = a;
a = b;
b = t;
}
if (a < c) {
int t = a;
a = c;
c = t;
}
if (b < c) {
int t = b;
b = c;
c = t;
}
system.out.println( "从大到小的顺序输出:" );
system.out.println(a + " " + b + " " + c);
}
}
|
以上这篇java 输入3个数a,b,c,按大小顺序输出的实例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/iamdingruihaha/article/details/74643804