求三个整数的最大值
Time Limit: 1000MS
Memory Limit: 65536KB
Problem Description
请编写程序,输入三个整数,求出其中的最大值输出。
Input
在一行上输入三个整数,整数间用逗号分隔。
Output
输出三个数中的最大值。
Example Input
5,7,9
Example Output
max=9
01 | import java.util.*; |
02 |
03 | public class Main { |
04 | public static void main(String args[]){ |
05 | Scanner input = new Scanner(System.in); |
06 | String aa = null ; |
07 | aa = input.nextLine(); |
08 | String[] bb = aa.split( "," ); |
09 | |
10 | int max = 0 ; |
11 | int [] cc = new int [bb.length]; |
12 | for ( int i = 0 ;i<bb.length;i++){ |
13 | cc[i] = Integer.parseInt(bb[i]); |
14 | } |
15 | |
16 | for ( int i = 0 ; i <cc.length ; i++ ) { |
17 | |
18 | if (cc[i]>max){ |
19 | max = cc[i]; |
20 | } |
21 | } |
22 | System.out.println( "max=" +max); |
23 | } |
24 | } |
25 |
重点:关于split();函数的用法