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();
- }
- }
本文介绍了一个简单的Java程序,该程序通过读取一行包含三个整数的输入,并使用逗号作为分隔符来确定并输出这三个数中的最大值。程序首先利用Scanner类获取用户输入,然后通过条件判断找出最大数值。
1599

被折叠的 条评论
为什么被折叠?



