首页 > 代码库 > HW7.3
HW7.3
1 public class Solution 2 { 3 public static void main(String[] args) 4 { 5 char[][] answers = 6 { 7 {‘A‘, ‘B‘, ‘A‘, ‘C‘, ‘C‘, ‘D‘, ‘E‘, ‘E‘, ‘A‘, ‘D‘}, 8 {‘D‘, ‘B‘, ‘A‘, ‘B‘, ‘C‘, ‘A‘, ‘E‘, ‘E‘, ‘A‘, ‘D‘}, 9 {‘E‘, ‘D‘, ‘D‘, ‘A‘, ‘C‘, ‘B‘, ‘E‘, ‘E‘, ‘A‘, ‘D‘}, 10 {‘C‘, ‘B‘, ‘A‘, ‘E‘, ‘D‘, ‘C‘, ‘E‘, ‘E‘, ‘A‘, ‘D‘}, 11 {‘A‘, ‘B‘, ‘D‘, ‘C‘, ‘C‘, ‘D‘, ‘E‘, ‘E‘, ‘A‘, ‘D‘}, 12 {‘B‘, ‘B‘, ‘E‘, ‘C‘, ‘C‘, ‘D‘, ‘E‘, ‘E‘, ‘A‘, ‘D‘}, 13 {‘B‘, ‘B‘, ‘A‘, ‘C‘, ‘C‘, ‘D‘, ‘E‘, ‘E‘, ‘A‘, ‘D‘}, 14 {‘E‘, ‘B‘, ‘E‘, ‘C‘, ‘C‘, ‘D‘, ‘E‘, ‘E‘, ‘A‘, ‘D‘}15 };16 17 char[] keys = {‘D‘, ‘B‘, ‘D‘, ‘C‘, ‘C‘, ‘D‘, ‘A‘, ‘E‘, ‘A‘, ‘D‘};18 int[] students = new int[10];19 int[] correctCount = new int[10];20 int temp;21 22 for(int i = 0; i < 10; i++)23 students[i] = i;24 for(int i = 0; i < answers.length; i++)25 {26 for(int j = 0; j < answers[i].length; j++)27 if(answers[i][j] == keys[j])28 correctCount[i]++;29 }30 31 for(int i = 0; i < 10; i++)32 {33 for(int j = i; j < 10; j++)34 {35 if(correctCount[j] > correctCount[i])36 {37 temp = correctCount[j];38 correctCount[j] = correctCount[i];39 correctCount[i] = temp;40 temp = students[j];41 students[j] = students[i];42 students[i] = temp;43 }44 }45 }46 47 for(int i = 0; i < 10; i++)48 System.out.println("Student " + students[i] + "‘s correct count is " + correctCount[i]);49 }50 }
HW7.3
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。