/** * 需求:基本练习 * 思路:输入一个数进行比较,三元运算符; * * 步骤:略 */ import java.util.Scanner; public class Demo_1{ public static void main(String[] arge) { Scanner input = new Scanner(System.in); System.out.println("please enter two number: "); int X = input.nextInt(); int Y = input.nextInt(); int temp=X>Y?X:Y;//比较两个数字的打字 System.out.println("temp="+temp); Scanner input1 = new Scanner(System.in); System.out.println("please enter three number: "); int i = input1.nextInt(); int j = input1.nextInt(); int k = input1.nextInt(); int temp2=i>j?i:j;//比较两个数字的打字 int temp1=temp2>k?temp2:k; System.out.println("temp1="+temp1); } }
比较大小
This moment will nap, you will have a dream; but this moment study, you will interpret a dream.