本帖最后由 在学野马 于 2014-10-14 14:46 编辑
- public static void main(String[] args) throws Exception {
- // TODO Auto-generated method stub
- BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
- BufferedWriter bfw=new BufferedWriter(new FileWriter("c:\\stud.txt"));
- String line=null;
- while((line=bfr.readLine())!=null){
- if(line.equals("end"))
- break;
- bfw.write(shuzu(line));
- bfw.newLine();
- bfw.flush();
- }
- bfr.close();
- bfw.close();
- }
- private static int shuzu(String line) {
- // TODO Auto-generated method stub
- line=line.substring(1, line.length()-1);
- String[]str=line.split(",");
- int[]arr=new int[str.length];
- int max=arr[0];
- for(int i=0;i<str.length;i++){
- int m=Integer.parseInt(str[i]);
- arr[i]=m;
- }
- for(int i=0;i<arr.length;i++){
- if(max<arr[i]){
- max=arr[i];
- }
- }
- System.out.println(max);
- return max;
- }
复制代码
|
|