日期:2014-05-20 浏览次数:20971 次
import java.util.*;
public class delstr
{
    public static void main(String[] args) 
    {
        String temp="";
        String[][] sedstr =new String[5][];
        int [][] ret =  new int [6][5]; 
        Scanner in = new Scanner(System.in);
        int i=0;
        while (i<5)
        {
            temp=in.next();
            sedstr[i]=temp.split(";");
            i++;
        }
        if (strToInt(sedstr,ret)){
            System.out.println("\n输入数据合法!\n结果:");
            for (int k=0;k<5;k++){
                if (k<4){
                    System.out.print(ret[5][k] + ";");    
                }else{
                    System.out.print(ret[5][k]);    
                }    
            }
        }
    }
    
    public static boolean strToInt(String[][] aStr,int [][] aInt){
        int total=0;
        for (int j=0;j<5;j++){
            for (int i=0;i<5;i++){
              aInt[i][j]=Integer.parseInt(aStr[i][j]);
              if (aInt[i][j]>50){
                  System.out.println("第 "+ (i+1) + " 行,第 " + (j+1) + "列的值 大于50!");
                  return false;
              }
              total +=aInt[i][j];
            }
            aInt[5][j]=total;
            total=0;
        }
        return true;
    }
}
------解决方案--------------------
怎么我用Eclipse编译不出来呢`~