-5
 String[] B= {"2","14","5","12","10"};
 String[] I= {"20","25","18","16","22"};
 String[] N= {"42","32","FREE","31","39"};
 String[] G= {"60","55","53","46","59"};
 String[] O= {"64","70","67","75","71"};

 System.out.format();
}

}

预期答案:

答对了
2 20 42 60 64
14 25 32 55 70
5 18 免费 53 67
12 16 31 46 75
10 22 39 59 71
4

2 回答 2

1

解决方案是使用%-<n>s<n>您需要的“列”长度在哪里:

System.out.printf("'%-8s%-8s'\n", "hello", "world");

给出:

'hello   world   '

请注意,更一般地,您可以使用Formatter. 这就是printf()用途。

于 2013-07-08T11:13:57.983 回答
0

您可以使用此代码获得预期的输出

    String[] B = {"2", "14", "5", "12", "10"};
    String[] I = {"20", "25", "18", "16", "22"};
    String[] N = {"42", "32", "FREE", "31", "39"};
    String[] G = {"60", "55", "53", "46", "59"};
    String[] O = {"64", "70", "67", "75", "71"};

    String[][] test={B,I,N,G,O};
    int n=0;
    System.out.println("B  I  N  G  O");
    for(String[] str:test){
         for(int i=0;i<str.length;i++){
             System.out.print(test[i][n] + " ");
         }
        System.out.println("\n");
        n++;
    }
于 2013-07-08T12:15:44.113 回答