2020.4.2

输入三个整数x,y,z,请把这三个数由小到大输出(知识点:条件语句)

package sjfour;

import java.util.Scanner;

public class five {
          public static void main(String[] args){
                     Scanner sc=new Scanner(System.in);
                     System.out.println("请输入三个整数:");
                     int x=sc.nextInt();
                     int y=sc.nextInt();
                     int z=sc.nextInt();
                     int d;
                     if(x>y){
                         d=y;
                         y=x;
                         x=z;
                     }
                     if(x>z){
                         d=z;
                         z=x;
                         x=d;
                     }
                     if(y>z){
                         d=z;
                         z=y;
                         y=d;
                     }
                     System.out.println(x+" "+y+" "+z);
                 }
             }

 

posted @ 2020-04-02 09:12  Yik-  阅读(88)  评论(0编辑  收藏  举报