根据学生的总分进行等级比例的划分该如何进行?求解?

根据学生数量,对学生进行等级划分,
(比如:若干学生,先按照总分进行排序,然后从高到低的顺序20%为A,30%为B,40%为C,10%为D的顺序进行划分等)

            //按成绩降序排序的学生集合
    List<T> studentList = new ArrayList<>();
    //业务具体的学生总数
    int studentTotalCount = 1000;
    //A等级的studentList的最后一个人的下标
    int levelACount = (int)(studentTotalCount*0.2)-1;
    //B等级的studentList的下最后一个人的下标
    int levelBCount = (int)(studentTotalCount*(0.2+0.3))-1;
    //C等级的studentList的下最后一个人的下标
    int levelCCount = (int)(studentTotalCount*(0.2+0.3+0.4))-1;
    //D等级的studentList的下最后一个人的下标
    int levelDCount = studentTotalCount-1;
    //数组下标
    int index = 0;
    for(T t:studentList){
        if(index <=levelACount){
            t.setLevel("A");
        }else if(index <=levelBCount){
            t.setLevel("B"); 
        }else if(index <=levelCCount){
            t.setLevel("C");
        }else {
            t.setLevel("D");
        }
        index++;
    }
    //批量修改设置等级属性
    ......

先根据总数获取每个等级的学生数,然后根据分数对学生进行排序,之后根据每个等级的人数根据数组下标截取数组

根据20%,30%,40%,10%,通过学生数量总数乘以它们各自的比例得到他们各个比例的学生数量就然后从已经排好序的队列进行抽取相应数量就好了。

有100 学生。
a人数=100*20%;//20
b人数=100*30%;//30
c人数=100*40%;//40
d人数=100*10%;//10

a等级 0-20
b等级21-50;
c等级51-90;
d等级91-100;

 #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include <conio.h>
#include <ctype.h>

/*设置控制台窗口标题*/
void SetTitle(char *title);
/*设置文字色*/
/*
    黑=0     蓝=1    绿=2     湖蓝=3
    红=4     紫=5    黄=6     白=7
    灰=8     淡蓝=9  淡绿=10   亮蓝=11
    淡红=12   淡紫=13  淡黄=14   亮白=15
*/
void SetColor(int foreColor,int backColor);
/*设置光标位置*/
void SetPosition(int x,int y);
/*打印菜单*/
void ShowCD(void);
/*高->低,排序*/
void PaiXu();
/*排序+分类*/
void PX_FL();

int Max_count;//先设置学生的数量
int max_name; //设置学生名字的数量
char Caidan [3][15]={"1.排列名次;","2.筛选等级;","3.取消运行."};//菜单
int CDzb_Y=0;//菜单坐标
double Index[4]={20,30,40,10};
int Xueshen_count[100];   //学生分数的数组。
char Xueshen_name[100][10];//学生名字的数组,每个学生的名字可以有5个中文字。

void SetTitle(char *title)
{
    SetConsoleTitle(title);
}
void SetColor(int foreColor,int backColor)
{
    HANDLE winHandle;//句柄
    winHandle=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(winHandle,foreColor + backColor * 0x10);
}
void SetPosition(int x,int y)
{
    HANDLE winHandle;//句柄
    COORD pos={x,y};
    winHandle=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(winHandle,pos);
}
void ShowCD(void)
{
    int i,j;
    SetColor(12,0);
    SetPosition(0,0);
    printf("------------------------------------选择功能------------------------------------");
    SetPosition(0,1);
    for(i=0;i<3;i++)
    {
        for(j=0;j<1;j++)
        {
            if(i==CDzb_Y)
            {
                SetColor(0,15);
                printf("%s",Caidan[i]);
            }
            else
            {
                SetColor(10,0);
                printf("%s",Caidan[i]);
            }
        }
        printf("\n");
    }
}
void PaiXu()
{
    int i,j;
    int count[Max_count];
    int temp;
    for(i=0;i<Max_count;i++)
    {
        count[i]=Xueshen_count[i];
    }
    for(i=0;i<Max_count-1;i++)
    {
        for(j=0;j<Max_count-i-1;j++)
        {
            if(count[j]<count[j+1])
            {
                temp=count[j];
                count[j]=count[j+1];
                count[j+1]=temp;
            }
        }
    }
    system("cls");
    SetColor(12,0);
    printf("-------------------------------------排名榜-------------------------------------");
    SetColor(10,0);
    for(i=0;i<Max_count;i++)
    {
        for(j=0;j<Max_count;j++)
        {
            if(count[i]==Xueshen_count[j])
            {
                SetPosition(35,i+1);
                printf("第%d名:%s\n",i+1,Xueshen_name[j]);
            }
        }
    }
}
void PX_FL()
{
    int i,j,k;
    int count[Max_count];
    int temp;
    for(i=0;i<Max_count;i++)
    {
        count[i]=Xueshen_count[i];
    }
    for(i=0;i<Max_count-1;i++)
    {
        for(j=0;j<Max_count-i-1;j++)
        {
            if(count[j]<count[j+1])
            {
                temp=count[j];
                count[j]=count[j+1];
                count[j+1]=temp;
            }
        }
    }
    Sleep(5000);
    system("cls");
    SetColor(12,0);
    printf("------------------------------------A等-------------------------------------\n");
    SetColor(10,0);
    for(i=0;i<2;i++)
    {
        for(j=0;j<2;j++)
        {
            for(k=0;k<Max_count;k++)
            {
                if(count[j]==count[k])
                {
                    printf("%s\n",Xueshen_name[k]);
                }
            }
        }
    }
    SetColor(12,0);
    printf("------------------------------------B等-------------------------------------\n");
    SetColor(3,0);
    for(i=0;i<3;i++)
    {
        for(j=2;j<5;j++)
        {
            for(k=0;k<Max_count;k++)
            {
                if(count[j]==count[k])
                {
                    printf("%s\n",Xueshen_name[k]);
                }
            }
        }
    }
    SetColor(12,0);
    printf("------------------------------------C等-------------------------------------\n");
    SetColor(6,0);
    for(i=0;i<4;i++)
    {
        for(j=5;j<9;j++)
        {
            for(k=0;k<Max_count;k++)
            {
                if(count[j]==count[k])
                {
                    printf("%s\n",Xueshen_name[k]);
                }
            }
        }
    }
    SetColor(12,0);
    printf("------------------------------------D等-------------------------------------\n");
    SetColor(4,0);
    for(i=0;i<1;i++)
    {
        for(j=9;j<10;j++)
        {
            for(k=0;k<Max_count;k++)
            {
                if(count[j]==count[k])
                {
                    printf("%s\n",Xueshen_name[k]);
                }
            }
        }
    }
}

int main(void)
{
    int i;
    char key;
    Max_count=0;
    max_name=0;
    Xueshen_count[0]=-1;
    Xueshen_name;
    for (i=0;;i++)
    {
        SetColor(12,0);
        printf("------------------------------------注册学生------------------------------------\n");
        SetColor(11,0);
        printf("请输入第%d个学生的姓名(输入后按下Enter键):",i+1);
        SetColor(14,0);
        scanf("%s", &Xueshen_name[i]);
        SetColor(11,0);
        printf("请输入第%d个学生的分数(输入后按下Enter键):",i+1);
        SetColor(14,0);
        scanf("%d", &Xueshen_count[i]);
        SetColor(13,0);
        printf("如果注册完成请按按Esc键,否则请按Enter键.");
        key=_getch();
        if(key==27)
        {
            Max_count++;
            max_name++;
            system("cls");
            break;
        }
        else if(key==13)
        {
            Max_count++;
            max_name++;
            system("cls");
        }
    }
    while(1)
    {
        ShowCD();
        key=_getch();
        switch(key)
        {
            case 72:
                CDzb_Y--;
                break;
            case 80:
                CDzb_Y++;
                break;
            case 13:
                if(CDzb_Y==0)
                {
                    PaiXu();
                    SetPosition(Xueshen_count+1,4);
                    SetColor(9,0);
                    exit(0);
                }
                if(CDzb_Y==1)
                {
                    PX_FL();
                    SetColor(9,0);
                    exit(0);
                }
                if(CDzb_Y==2)
                {
                    SetPosition(0,4);
                    SetColor(9,0);
                    exit(0);
                }
        }
        if(CDzb_Y==3) CDzb_Y=0;
        if(CDzb_Y<0) CDzb_Y=2;
    }
    return 0;
}