0_0_2998325_5651\Main.java:1: 进行语法解析时已到达文件结尾
import java.util.Scanner;public class Main { static boolean canput(int row,int col,char[][] cityP) { int i; for (i=row-1;i>=0;i--) { if (cityP[i][col]=='O') return false; if (cityP[i][col]=='X') break; } for (i=row+1;i<cityP.length;i++) { if (cityP[i][col]=='O') return false; if (cityP[i][col]=='X') break; } for (i=col-1;i>=0;i--) { if (cityP[row][i]=='O') return false; if (cityP[row][i]=='X') break; } for (i=col+1;i<cityP.length;i++) { if (cityP[row][i]=='O') return false; if (cityP[row][i]=='X') break; } return true; } static int numCounter(int k,char[][] cityP) { int infoLen = cityP.length; int maxNum = 0; int numofCandidate = 0; for (int i=0;i<infoLen;i++) for (int j=0;j<infoLen;j++) { if(cityP[i][j] == '.' & canput(i,j,cityP)) { cityP[i][j]='O'; //System.out.println(Arrays.deepToString(cityP)); numofCandidate = numCounter((i*infoLen+j+1),cityP)+1; if (numofCandidate > maxNum) maxNum = numofCandidate; cityP[i][j]='.'; } } //System.out.println(maxNum); return maxNum; } public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNextInt()) { int outLoop = in.nextInt(); int k = 0; if (outLoop == 0) break; char[][] cityProfile = new char[outLoop][outLoop]; String nowstr; for (int i=0;i<outLoop;i++) { nowstr = in.next(); for (int j=0;j<outLoop;j++) cityProfile[i][j]=nowstr.charAt(j); } //System.out.println(Arrays.deepToString(cityProfile)); k = numCounter(0,cityProfile); System.out.println(k); } } }
|