您的位置:首页 > 其它

求三个整数的最大值

2018-03-23 16:59 232 查看


Problem Description

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

Input

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

Output

输出三个数中的最大值。

Sample Input

5,7,9

Sample Output

max=9

Hint

Source

wy
[java] view plain copyimport java.util.Scanner;  
//import java.text.DecimalFormat;  
public class Main {  
    public static void main(String args[]) {  
    Scanner cin = new Scanner(System.in);  
   //DecimalFormat df = new DecimalFormat("0.00");  
    int a, b, t, c;  
    String ch = cin.nextLine();  
    String array[] = ch.split(",");//将字符串以逗号为界分离储存在数组中  
    a = Integer.parseInt(array[0]);//将数组中的值提出出来  
    b = Integer.parseInt(array[1]);  
    c = Integer.parseInt(array[2]);  
    if(a > b && a > c)  
    {  
        t = a;  
    }  
    else if(b > a && b > c)  
    {  
        t = b;  
    }  
    else  
    {  
        t = c;  
    }  
    System.out.println("max=" + t);  
    cin.close();  
    }  
}  
   
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐