ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 得分排行

得分排行

原创 Linux操作系统 作者:jm_gao 时间:2010-05-27 17:47:25 0 删除 编辑
public static void simpleRank() {    int count = 5;    int[] score = { 80, 70, 75, 100, 75 };    int[] juni = { 0, 0, 0, 0, 0 };    for (int i = 0; i < count; i++) {        juni[i] = 1;        for (int j = 0; j < count; j++) {        if (score[j] > score[i])            juni[i]++;        }    }    System.out.println("得分\t排行\n");    for (int i = 0; i < count; i++)        System.out.println("得分:" + score[i] + "排行:" + juni[i]);    }    public static void optimizeRank() throws IOException {    final int MAX = 100;    final int MIN = 0;    int[] score = new int[MAX + 1];    int[] juni = new int[MAX + 2];    BufferedReader reader = new BufferedReader(new InputStreamReader(        System.in));    int count = 0;    do {        System.out.print("输入分数,-1结束:");        score[count++] = Integer.parseInt(reader.readLine());    } while ((score[count - 1] != -1));    count--;    for (int i = 0; i < count; i++)        juni[score[i]]++;    juni[MAX + 1] = 1;    for (int i = MAX; i >= MIN; i--)        juni[i] = juni[i] + juni[i + 1];    System.out.println("得分\t排行");    for (int i = 0; i < count; i++) {        System.out.println(score[i] + "\t" + juni[score[i] + 1]);    }    }

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15760276/viewspace-663873/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2008-09-06

  • 博文量
    11
  • 访问量
    23572