打印的内容“亚里士多德”超过了八位导致多输出八个空格。
但是写成System.out.printf("%-12s",y[i/6][i%6])的话,输出是会将中文一个字看成一位,在后面补齐剩余的空格。
有没有解决方案,感谢。
String[] x = {"李大牛","李二牛","王莽","赵匡胤","松江","孙悟空","宋玉","李煜","白居易","宋霭龄","爱新觉罗","宋工","欧阳修","李冰","维克多","路易十六","亚里士多德","苏格拉底"};
String[][] y =new String[3][6];
for(int i=0;i<x.length;i++){
y[i/6][i%6] = x[i];
System.out.printf("%s\t\t",y[i/6][i%6]);
if(i%6==5&i!=x.length-1)
System.out.println();
}