成绩排名——华为上机笔试题

成绩排名——华为上机笔试题_第1张图片




import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        ArrayList list = new ArrayList();
    	ArrayList mathlevel = new ArrayList();
    	ArrayList langlevel = new ArrayList();
    	ArrayList totallevel = new ArrayList();
        while(sc.hasNext()){
        	String cmd = sc.nextLine();
        	String[] fen = cmd.split(":|,|;|=");
        	String name="";
        	int mathgrade=0,langgrade=0;
        	boolean flag = true;
        	for(int i = 0; i list){
		int count = 0;
		Collections.sort(list,new SortbyInt());
		for(int i:list){
			count++;
			if(grade == i){
				break;
			}
		}
		return count;
	}
    
}

class Person{
	String name;
	int mathgrade;
	int langgrade;
	public Person(String name, int mathgrade, int langgrade) {		
		this.name = name;
		this.mathgrade = mathgrade;
		this.langgrade = langgrade;
	}
	
}
class SortbyInt implements Comparator{

	@Override
	public int compare(Object o1, Object o2) {
		// TODO Auto-generated method stub
		int i1 =(int)o1;
		int i2 =(int)o2;
		if(i1>i2){
			return -1;
		}
		return 1;
		
	}
	
}





你可能感兴趣的:(JAVA)