【得分排行】

/*
得分排行 
*/
#include<stdio.h>
#include<stdlib.h>

#define MAX 100
#define MIN 0 

int main(void)
{
    int score[MAX + 1] = {0};
    int juni[MAX + 2] = {0};
    int count = 0, i;
    
    printf("输入分数, -1 结束:");
    do
    {
        scanf("%d", &score[count++]);
    }while(score[count - 1] != -1);
    count--;
    
    for(i =  0; i < count; i++)
    {
        juni[score[i]]++;
    }
    juni[MAX + 1] = 1;
    
    for(i = MAX; i >= MIN; i--)
    {
        juni[i] = juni[i] + juni[i + 1];
    }
    printf("得分\t排行\n");
    
    for(i = 0; i < count; i++)
    {
        printf("%d\t%d\n", score[i], juni[score[i] + 1]);
    }
    return 0;
} 

 

运行结果:

 

posted @ 2017-02-01 18:03  天秤libra  阅读(1140)  评论(0编辑  收藏  举报