Problem 1002 本地没问题,提交时却显示runtime error 求解

jiaxiaohuiluoxue | 2016-05-12 14:29:19Author
package jiajiemi; import java.util.Scanner; class jiajiemi { @SuppressWarnings("null") public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); System.out.println("input your mi yao K"); int k=sc.nextInt(); System.out.println("input the mi wen"); Scanner sc1=new Scanner(System.in); String str1=sc1.nextLine(); String []str=new String[str1.length()]; for(int i=0;i<str1.length();i++){ str[i] = str1.substring(i,i+1); } int length=str.length; int yushu=length%k; int row; if(length%k==0) row=length/k; else row=(length/k+1); String [][]strdoublearray =new String[row][k]; System.out.println(yushu+" "+row+" "+length); if(yushu!=0){ int len=0; for(int i=0;i<k;i++){ for(int j=0;j<row;j++){ if(j==(row-1)&&i>=yushu) { strdoublearray[j][i]=" "; } else { strdoublearray[j][i]=str[len]; ++len; } } } } else{ int len=0; for(int i=0;i<k;i++){ for(int j=0;j<row;j++){ //for(int len=0;len<str.length;len++) strdoublearray[j][i]=str[len]; ++len; } } } for(int i=0;i<row;i++){ for(int j=0;j<k;j++){ System.out.print(strdoublearray[i][j]); if(strdoublearray[i][j]==" "){ break; } } } } }
pinyoufu | 2016-05-13 21:19:26# 1
我也遇到这个问题了,楼主有没有找到解决办法?