[Java/Python]输出两数中的最小数 one-liner
Java
import java.util.Scanner; public class compare { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("input your first number: "); int a = scan.nextInt(); System.out.println("input your second number: "); int b = scan.nextInt(); System.out.printf("the smaller number is %d.%n", a < b ? a : b); } }
输出的结果可以是:
input your first number: 56 input your second number: -9 the smaller number is -9.
Python:
a = int(input("input your first number: \n")) b = int(input("input your second number: \n")) print(f"the smaller number is {a if a < b else b}") #或者: # print(f"the smaller number is {min(a, b)}")
相关推荐
huha 2020-10-16
TLROJE 2020-10-26
echoes 2020-08-20
nercon 2020-08-01
zhanghaibing00 2020-06-28
Aveiox 2020-06-25
henryzhihua 2020-06-21
zhoutaifeng 2020-06-17
liangzhouqu 2020-06-16
TONIYH 2020-06-11
开心就好 2020-06-10
x青年欢乐多 2020-06-06
KyrieHe 2020-06-03
bertzhang 2020-06-02
niehanmin 2020-05-28
davidliu00 2020-05-26
JackLang 2020-05-15