public static void main(String[] args) {
// TODO 自动生成的方法存根
int[][]arr= {{91,25,8},{56,14,2},{47,3,67}};
int a=0;
int b=0;
for(a=0;a<=arr.length;a++)/*外循环*/ {
for(b=0;b<3;b++) /*内循环*/{
System.out.print(arr[b][a]);
System.out.print(" ");
}System.out.println("");//转行
}
}
结果:
第二题
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);//创建扫描器
char A[]=new char[]{'B','A','D','C','C','B','C','A','D','B'};
System.out.println("你想调取第几位学生答案");
int num=sc.nextInt();
int c=0;
char B[][]={{'A','A','B','B','C','C','D','D','A','B',0,0},{'B','A','D','C','C','B','C','A','D','B'},{'B','A','D','C','C','B','C','A','D','a'}
,{'A','A','B','B','C','C','D','D','A','A'},{'A','A','B','B','C','C','D','D','A','B'},{'B','A','D','C','C','B','C','A','D','B'},
{'A','A','B','B','C','C','D','D','A','B'},{'A','A','B','B','C','C','D','D','A','B'}};
for(int i=0;i<num;i++) {
for(int j=0;j<10;j++) {
if(i==num-1) {
System.out.print(B[i][j]);
System.out.print(" ");
if(A[j]==B[i][j]) {
c++;
}
}
}
}
System.out.print("第"+num+"位同学一共对了"+c+"道题");
sc.close();
}
结果: