class.c

mail@pastecode.io avatar
unknown
plain_text
7 months ago
726 B
6
Indexable
Never
#include <stdio.h>

int main()
{
    int people, rank;
 
    int score[10000];
    int score_1[10000]; //用於統計每個分數分別有幾人
    scanf("%d", &people);
    scanf("%d", &rank);

    for (int i = 0; i < people; i++)
    {
        scanf("%d", &score[i]);
        int num = score[i];
        score_1[num]++;
    }    

    int a;
    int total = 0;

    for (int i = 0; i <= 100; i++)
    {
        total += score_1[i];

        if (total < rank && score_1[i] != 0) //上一名的分數
            a = i;
        
        if (total >= rank)
        {   
            float ans = a + i;
            printf("%.1f", ans / 2);
            break;
        }
    }

    return 0;
}
Leave a Comment