HW7.3
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的更多相关文章
- HW7.18
public class Solution { public static void main(String[] args) { int[][] m = {{1, 2}, {3, 4}, {5, 6} ...
- HW7.17
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.16
import java.util.Arrays; public class Solution { public static void main(String[] args) { int row = ...
- HW7.15
public class Solution { public static void main(String[] args) { double[][] set1 = {{1, 1}, {2, 2}, ...
- HW7.14
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.13
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.12
import java.util.Scanner; public class Solution { public static void main(String[] args) { double[] ...
- HW7.11
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW7.10
public class Solution { public static void main(String[] args) { int[][] array = new int[3][3]; for( ...
- HW7.9
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
随机推荐
- 使用JS创建表格以及隔行换色(包括隔N行换色)
<html> <head> <title></title> <style> table{ width:800px; border-colla ...
- Mac中编译安装Qt 4.4
解压下载到的.gz源码:gunzip xxx.tar.gztar xvf xxx.tar, 其实在Mac中可以直接双击解压的.然后定位到解压后的目录下:./configuremakesudo make ...
- 函数可重入问题reentrant functions(函数执行过程中可以被中断,允许多个副本)
最近经常听到这个名词,以前也听到过,不过接触更多的是“线程安全问题”,而且本人也一直理解的是两个名字的含义是一样的.今天仔细总结一下这个名词相关的概念. 引用博文:可重入函数和不可重入函数 (http ...
- zip文件解压或压缩
<span style="font-size:18px;">/** * lsz */ public final class ZipUtil { /** * 解压zip文 ...
- meta的Name为apple-itunes-app 是什么意思
例如:<meta name="apple-itunes-app" content="app-id=432274380" /> 解答:这个标签是告诉i ...
- default parameter value for ‘color’ must be a compile-time constant
定义了一个函数,函数有一个参数是Color类型的可选参数,想要设置其默认值为Color.Black http://stackoverflow.com/questions/2804395/c-sharp ...
- Counting sheep...
Counting sheep... Description: Consider an array of sheep where some sheep may be missing from their ...
- HTML5学习(七)----地理定位
参考教程:http://www.w3school.com.cn/html5/html_5_geolocation.asp 说明:设备必须有GPS定位功能才能定位的 定位用户的位置 HTML5 Geol ...
- Weblogic11g安装
我们在64位的服务器上为提高性能要安装64位的weblogic.经常在网上看到有人问,weblogic有64位的么?weblogic需要破解么? weblogic有专门的64位版本,这里安装的是web ...
- TortoiseGit连接github不用每次输入用户名和密码的方法
每次git clone 和push 都要输入用户名和密码.虽然安全,但在本机上每次都输有些麻烦,如何记住用户名和密码呢? 当你配置好git后,在C:\Documents and Settings\Ad ...