haokele 2020-05-29
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)}")
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" width="100%&qu