public class Solution
 {
     public static void main(String[] args)
     {
         char[][] answers =
         {
             {'A', 'B', 'A', 'C', 'C', 'D', 'E', 'E', 'A', 'D'},
             {'D', 'B', 'A', 'B', 'C', 'A', 'E', 'E', 'A', 'D'},
             {'E', 'D', 'D', 'A', 'C', 'B', 'E', 'E', 'A', 'D'},
             {'C', 'B', 'A', 'E', 'D', 'C', 'E', 'E', 'A', 'D'},
             {'A', 'B', 'D', 'C', 'C', 'D', 'E', 'E', 'A', 'D'},
             {'B', 'B', 'E', 'C', 'C', 'D', 'E', 'E', 'A', 'D'},
             {'B', 'B', 'A', 'C', 'C', 'D', 'E', 'E', 'A', 'D'},
             {'E', 'B', 'E', 'C', 'C', 'D', 'E', 'E', 'A', 'D'}
         };

         char[] keys = {'D', 'B', 'D', 'C', 'C', 'D', 'A', 'E', 'A', 'D'};
         int[] students = new int[10];
         int[] correctCount = new int[10];
         int temp;

         for(int i = 0; i < 10; i++)
             students[i] = i;
         for(int i = 0; i < answers.length; i++)
         {
             for(int j = 0; j < answers[i].length; j++)
                 if(answers[i][j] == keys[j])
                     correctCount[i]++;
         }

         for(int i = 0; i < 10; i++)
         {
             for(int j = i; j < 10; j++)
             {
                 if(correctCount[j] > correctCount[i])
                 {
                     temp = correctCount[j];
                     correctCount[j] = correctCount[i];
                     correctCount[i] = temp;
                     temp = students[j];
                     students[j] = students[i];
                     students[i] = temp;
                 }
             }
         }

         for(int i = 0; i < 10; i++)
             System.out.println("Student " + students[i] + "'s correct count is " + correctCount[i]);
     }
 }

HW7.3的更多相关文章

  1. HW7.18

    public class Solution { public static void main(String[] args) { int[][] m = {{1, 2}, {3, 4}, {5, 6} ...

  2. HW7.17

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  3. HW7.16

    import java.util.Arrays; public class Solution { public static void main(String[] args) { int row = ...

  4. HW7.15

    public class Solution { public static void main(String[] args) { double[][] set1 = {{1, 1}, {2, 2}, ...

  5. HW7.14

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  6. HW7.13

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  7. HW7.12

    import java.util.Scanner; public class Solution { public static void main(String[] args) { double[] ...

  8. HW7.11

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  9. HW7.10

    public class Solution { public static void main(String[] args) { int[][] array = new int[3][3]; for( ...

  10. HW7.9

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

随机推荐

  1. Android ListView相关 fastScrollEnabled

    1.android:fastScrollEnabled="true" 当数据量比较多的时候,右侧会出现一个可以拉动的滚动条,这样可以很快的拉动,如图:

  2. cocos2d-x3.9 NDK android 环境搭建过程中遇到的错误

    编译环境:Mac OS, NDK r9d 错误:arm-linux-androideabi-gcc: error trying to exec '/media/Project/adt-bundle-l ...

  3. [译]C++书籍终极推荐

    转载声明: 翻译仅以技术学习和交流为目的,如需转载请务必标明原帖链接. 来源:http://stackoverflow.com/questions/388242/the-definitive-c-bo ...

  4. Repeater, DataList, 和GridView控件的区别

    http://blog.sina.com.cn/s/blog_646dc75c0100h5p6.html http://www.cnblogs.com/phone/archive/2010/09/15 ...

  5. 【转】wireshark过滤规则

    WireShark过滤语法 1.过滤IP,如来源IP或者目标IP等于某个IP 例子:ip.src eq 192.168.1.107 or ip.dst eq 192.168.1.107或者ip.add ...

  6. update多表陷阱

    今天同学发了个sql题目 A1表 B1表 id num id snum 1 10 1 90 2 2000 3 4000 3 30 B表的数据插入A表当中 最后的结果 A表 1 90 2 2000 3 ...

  7. Python生成器与yield

    列表推导与生成器表达式 当我们创建了一个列表的时候,就创建了一个可以迭代的对象: >>> squares=[n*n for n in range(3)] >>> f ...

  8. 关于haproxy hdr_reg(host) 的一些解释

    I've recently taken over an environment using HAProxy, and I'm attempting to learn the config and wh ...

  9. NFC(9)NDEF文本格式规范及读写示例(解析与封装ndef 文本)

    只有遵守NDEF文本格式规范的数据才能写到nfc标签上. NDEF文本格式规范 不管什么格式的数据本质上都是由一些字节组成的.对于NDEF文本格式来说. 1,这些数据的第1个字节描述了数据的状态, 2 ...

  10. 关于xml的一些知识,DTD,XSD

    DTD 文档类型定义(Document Type Definition)是一套关于标记符的语法规则.它是标准通用标记语言和 可扩展标记语言1.0版规格的一部分,是文档的验证机制.文档类型定义是一种保证 ...