码迷,mamicode.com
首页 > 其他好文 > 详细

HW7.3

时间:2016-08-29 20:43:01      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

 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

标签:

原文地址:http://www.cnblogs.com/wood-python/p/5819543.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!