[java]代码库
import java.util.Arrays;
public class FUXI1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int [] javaScore={98,95,90,87,86,84,80,75,70,65};
int [] javaNo={1,5,2,3,4,6,7,10,8,9};
int [] htmlScore={95,94,91,88,85,82,80,79,77,70};
int [] htmlNo={2,4,1,8,7,5,3,6,10,9};
int htmlsum = 0;
int htmlavg = 0;
int javasum = 0;
int javaavg = 0;
//html平均成绩
for (int i = 0; i < htmlScore.length; i++) {
htmlsum = htmlsum + htmlScore[i];
}
htmlavg = htmlsum / htmlNo.length;
System.out.println("HTML科目的平均成绩是:" + htmlavg);
// java的平均成绩
for (int i = 0; i < javaScore.length; i++) {
javasum = javasum + javaScore[i];
}
javaavg = javasum / javaNo.length;
System.out.println("java科目的平均成绩是:" + javaavg+"\n");
//每个同学的总成绩
int all [] = new int [10];
for (int a = 0; a < javaNo.length; a++) {
for (int b = 0; b < htmlNo.length; b++) {
if (javaNo[a] == htmlNo[b]) {
all[a] = javaScore[a] + htmlScore[b];
}
}
System.out.println("第" + javaNo[a] + "位的同学总成绩是:" + all[a]);
}
Arrays.sort(all);
System.out.println("\n"+"总成绩从高到低依次为:");
for (int i = all.length-1; i >=0 &&i < all.length; i--) {
System.out.print("\t"+all[i]);
}
}
}