import java.util.Scanner;
public class 第五次作业 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int array[][] ={{91,25,8},{56,14,2},{47,3,67}}; //定义一个二维数组并定义它们
System.out.println("原始数组:"); //输出
for(int a = 0;a < 3;a++) { //for循环 行
for(int b = 0;b < 3;b++) { //for循环 列
System.out.print(array[a][b] +" "); //输出数组内的数字
} System.out.println(); //换行
}
System.out.println("改变后的数组:"); //输出"改变后的数组:"
for(int a = 0;a < 3;a++) { //for循环 行
for(int b = 0;b < 3;b++) { //for循环 列
int c = array[a][b];
System.out.print(array[b][a] +" "); //输出数组
}
System.out.println();
}
}
}
import java.util.Scanner;
public class 第五次作业 {
public static void main(String[] args) {
// TODO Auto-generated method stub
char cj[][] = {{'A','B','B','B','C','A','C','B','A','A'},{'C','A','C','A','B','B','B','A','C','B'},
{'A','C','D','C','C','B','C','A','D','B'},{'B','A','D','C','C','B','C','A','D','C'},
{'D','A','D','C','C','B','C','A','D','C'},{'C','A','D','C','C','B','C','A','D','C'},
{'B','A','D','C','C','B','C','A','D','A'},{'B','A','D','C','C','B','C','A','D','B'}, //把学生的答案全部用二维数组储存起来。
{'B','A','D','C','C','B','C','A','D','B'}};
System.out.println("您想调取第几位学生的答题结果(有效数字为1~8)"); //输出"您想调取第几位学生的答题结果(有效数字为1~8)"
Scanner sc = new Scanner(System.in); //创建扫描器
int a = sc.nextInt(); //接收控制台数字
int t = 0; //
System.out.println("第" + a + "位同学的全部答案为:"); //输出"第" + a + "位同学的全部答案为:"
for(int b = 0;b<10;b++) { //for循环用来学生答案
System.out.print(cj[a-1][b] + " ");
if(cj[a-1][b] == cj[8][b]) { //学生答案来和标准答案比较看对了多少
t++;
}
}System.out.println(); //换行
System.out.println("第二位同学一共答对了" + t + "道题"); //输出"第二位同学一共答对了" + t + "道题"
sc.close();
}
}