德才论

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

import java.util.ArrayList;

import java.util.Collections;

import java.util.Comparator;

import java.util.Scanner;

 

/*输出有四种类型

 *  类型一:德分>H且才分>H           才德全尽

 *  类型二:德分>H且L<才分<H   德胜才

 *  类型三:L<德<H且L<才分<H且德分>才分     才德兼亡(德胜才)

 *  类型四:L<德分<H且L<才分<H

 

 *  且数出时要数出达到最低分数线的考生人数

 */

public class Main {

     public static void main(String[] args) {

         class Student{

                String ID;

                int moral;

                int talent;

                Student(String id,int moral,int talent){

                    this.ID=id;

                    this.moral=moral;

                    this.talent=talent;

                }

         }

          

        ArrayList<Student> list1=new ArrayList<Student>();

        ArrayList<Student> list2=new ArrayList<Student>();

        ArrayList<Student> list3=new ArrayList<Student>();

        ArrayList<Student> list4=new ArrayList<Student>();

        Scanner in=new Scanner(System.in);

        int num=in.nextInt();

        int L=in.nextInt();

        int H=in.nextInt();

        Student[] stu=new Student[num];

        for(int i=0;i<num;i++){

            stu[i]=new Student(in.next(),in.nextInt(),in.nextInt());

            if(stu[i].moral>=H && stu[i].talent>=H)

                list1.add(stu[i]);

            else if(stu[i].moral>=H && stu[i].talent>=L)

                list2.add(stu[i]);

            else if(stu[i].moral>=L && stu[i].talent>=L && stu[i].moral>=stu[i].talent)

                list3.add(stu[i]);

            else if(stu[i].moral>=L && stu[i].talent>=L)

                list4.add(stu[i]);

        }      

        System.out.println(list1.size()+list2.size()+list3.size()+list4.size());//输出上线人数。

        Comparator<Student> com=new Comparator<Student>(){

 

            public int compare(Student o1, Student o2) {

                if(o1.moral+o1.talent>o2.moral+o2.talent)

                    return -1;

                else if(o1.moral+o1.talent<o2.moral+o2.talent)

                    return 1;

                else{

                    if(o1.moral>o2.moral)

                        return -1;

                    else if(o1.moral<o2.moral)

                        return 1;

                    else{

                        if(Integer.valueOf(o1.ID)<Integer.valueOf(o2.ID))

                            return -1;

                        else

                            return 1;

                    }

                }

                 

            }          

        };

        Collections.sort(list1,com);

        Collections.sort(list2,com);

        Collections.sort(list3,com);

        Collections.sort(list4,com);

        for(int i=0;i<list1.size();i++){//第一类输出

            String id=list1.get(i).ID;

            int m=list1.get(i).moral;

            int n=list1.get(i).talent;

            System.out.println(id+" "+m+" "+n);

        }

        for(int i=0;i<list2.size();i++){//第二类输出

            String id=list2.get(i).ID;

            int m=list2.get(i).moral;

            int n=list2.get(i).talent;

            System.out.println(id+" "+m+" "+n);

        }

        for(int i=0;i<list3.size();i++){//第三类输出

            String id=list3.get(i).ID;

            int m=list3.get(i).moral;

            int n=list3.get(i).talent;

            System.out.println(id+" "+m+" "+n);

        }

        for(int i=0;i<list4.size();i++){//第四类输出

            String id=list4.get(i).ID;

            int m=list4.get(i).moral;

            int n=list4.get(i).talent;

            System.out.println(id+" "+m+" "+n);

        }

        in.close();

    }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值