求三个整数的最大值

  • Post author:
  • Post category:其他





Problem Description


请编写程序,输入三个整数,求出其中的最大值输出。


Input


在一行上输入三个整数,整数间用逗号分隔。


Output


输出三个数中的最大值。


Sample Input


5,7,9


Sample Output


max=9


Hint



Source


wy


  1. import


    java.util.Scanner;



  2. //import java.text.DecimalFormat;





  3. public




    class


    Main {



  4. public




    static




    void


    main(String args[]) {


  5. Scanner cin =

    new


    Scanner(System.in);



  6. //DecimalFormat df = new DecimalFormat(“0.00”);





  7. int


    a, b, t, c;


  8. String ch = cin.nextLine();

  9. String array[] = ch.split(

    “,”


    );


    //将字符串以逗号为界分离储存在数组中




  10. a = Integer.parseInt(array[

    0


    ]);


    //将数组中的值提出出来




  11. b = Integer.parseInt(array[

    1


    ]);


  12. c = Integer.parseInt(array[

    2


    ]);



  13. if


    (a > b && a > c)


  14. {

  15. t = a;

  16. }


  17. else




    if


    (b > a && b > c)


  18. {

  19. t = b;

  20. }


  21. else




  22. {

  23. t = c;

  24. }

  25. System.out.println(

    “max=”


    + t);


  26. cin.close();

  27. }

  28. }