普歌-允异团队-java 求出三个数中的最小值

普歌-允异团队-求出三个数中的最小值

MikeCat

让用户依次录入三个整数,求出三个数中的最小值,并打印到控制台。

package mikecat1;

import java.util.Scanner;

/*
Scanner  ( ) ( ) ( )
        int i,j,k;
        q =(i>k)? i : k;
        w = (q >j )? q : j ;
        min  = w;

*/
public class Min {
    
    
    public static void main(String[] args) {
    
    
        int i,k,j;
        System.out.println("please input three numbers:");
        Scanner sc = new Scanner(System.in);
        i = sc.nextInt();
        j = sc.nextInt();
        k = sc.nextInt();
        int q;
        q = (i>k)? k : i;
        int w;
        w = (q >j )? j : q ;
        System.out.println("min = " + w);
    }
}

Run

please input three numbers:
99 66 1314
min = 66

Process finished with exit code 0

  • 作者:麦克猫Cat
  • 本文版权归作者和CSDN共有,欢迎转载,且在文章页面明显位置给出原文链接,未经作者同意必须保留此段声明,否则保留追究法律责任的权利。

猜你喜欢

转载自blog.csdn.net/weixin_52309367/article/details/111429870