Problem Description
请编写程序,输入三个整数,求出其中的最大值输出。
Input
在一行上输入三个整数,整数间用逗号分隔。
Output
输出三个数中的最大值。
Sample Input
5,7,9
Sample Output
max=9
Hint
Source
wy
- import 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();
- }
- }