比较大小


 

/**
 *  需求:基本练习
 *  思路:输入一个数进行比较,三元运算符;
 *   
 *  步骤:略
 */
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);
        
        
    }
}
    

 

 


 

 

posted on 2017-09-26 17:05  马文奇  阅读(199)  评论(0编辑  收藏  举报

导航