按以下代码无法输出正确的图形,为何?
package ch2;
public class Erweishuzu {
public static void main(String[] args) {
int [][]map ={{0,0,0,1,0,0,0},{0,0,1,0,1,0,0},{0,1,0,0,0,1,0},{1,0,0,0,0,0,1}
};
for(int row=0;row<map.length;row++){
for (int col=0;col<map[row].length;col++){
switch (map[row][col]){
case 0:
System.out.println(' ');
break;
case 1:
System.out.println('*');
break;
}
}
System.out.println();
}
}
}
你的System.out.println(' ');及System.out.println('*');
中的println要改为print
(你多回车了)
程序结果
热门标签: