InputStreamReader stdin = new InputStreamReader(System.in);
BufferedReader input = new BufferedReader(stdin);for(int y=0; y<3; y++){
for(int x=0; x<3; x++){
int a = 0;
int inputNo = 0;
String inputTile;
//tile = tiles[x+3*y];(这个可以忽略)
a = str.indexOf(' ');
if (a!=-1){
inputTile = str.substring(0,a).trim();
str = str.substring(a).trim();
}
else {
inputTile = str; }
try{
inputNo = Integer.parseInt(inputTile);
这里进行存储inputNo
} catch (NumberFormatException e) {
if (inputTile=="blank")
tile.Set(x, y, 3, 3);(这里也是在存储,也可以认为是用数字0来代替blank和其他数值村到一次)
else{
System.out.println("Invalid Input2");
System.exit(0);这段程序,本意是用来读取“2 3 5 blank 1 4 6 8 7”这样的字符串。然后分别存到一个arry中。如果读到blank。则存为零。原程序要复杂一些。我在这里简化了
BufferedReader input = new BufferedReader(stdin);for(int y=0; y<3; y++){
for(int x=0; x<3; x++){
int a = 0;
int inputNo = 0;
String inputTile;
//tile = tiles[x+3*y];(这个可以忽略)
a = str.indexOf(' ');
if (a!=-1){
inputTile = str.substring(0,a).trim();
str = str.substring(a).trim();
}
else {
inputTile = str; }
try{
inputNo = Integer.parseInt(inputTile);
这里进行存储inputNo
} catch (NumberFormatException e) {
if (inputTile=="blank")
tile.Set(x, y, 3, 3);(这里也是在存储,也可以认为是用数字0来代替blank和其他数值村到一次)
else{
System.out.println("Invalid Input2");
System.exit(0);这段程序,本意是用来读取“2 3 5 blank 1 4 6 8 7”这样的字符串。然后分别存到一个arry中。如果读到blank。则存为零。原程序要复杂一些。我在这里简化了
String[] temArry = aaa.split(" ");
int[] arry = new int[temArry.length];
for(int i = 0;i<temArry.length;i++)
{
if(temArry[i].equals("blank"))
{
arry[i] = 0;
}
else
{
arry[i] = Integer.parseInt(temArry[i]);
}
}
String aaa = "2 3 5 blank 1 4 6 8 7";
aaa = aaa.replaceAll("blank","0");
String args[] = aaa.split(" ");