zoukankan      html  css  js  c++  java
  • [Java/Python]输出两数中的最小数 one-liner

    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: 
    "))
    b = int(input("input your second number: 
    "))
    print(f"the smaller number is {a if a < b else b}")
    
    #或者:
    # print(f"the smaller number is {min(a, b)}")
  • 相关阅读:
    JS和Flash相互调用
    xml的应用
    随机验证码
    模块 time
    第一天 注册成功
    我的第一篇博客
    git
    2018-02-27
    25
    建站之星
  • 原文地址:https://www.cnblogs.com/profesor/p/12985429.html
Copyright © 2011-2022 走看看