学生成绩管理系统【C语言程序设计】

一、功能实现:0、浏览学生信息1、输入学生信息2、增加学生信息3、修改学生信息4、删除学生信息5、按学号查询6

大家好,又见面了,我是你们的朋友全栈君。一、功能实现:

0、浏览学生信息
1、输入学生信息
2、增加学生信息
3、修改学生信息
4、删除学生信息
5、按学号查询
6、按班级查询
7、按姓名查询
8、按课堂名称查询
9、按总分高低排序
10、单科成绩排名
11、查询班级优秀率
12、清屏
13、退出系统

二、运用到的核心知识:

0、动态链表的创建、输出、查找、增加、修改、删除等

1、链表的冒泡排序

三、代码如下:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define lis struct stu
#define setup (lis *)malloc(sizeof(lis))

struct score
{
    float ord_scor;
    //expe_scor,exam_scor;//可增加学生单科各类成绩,为简便,在此忽略
};

struct stu
{
    int num;
    char name[10];
    struct score Chinese, Math, English, Physics, Chem, Bio;
    float fina_scor;
    lis *next;
};

lis *p;

lis *input()//输入学生信息
{
    lis *head, *tail;
    int cnt = 0;
    p = setup;
    printf( "学号  姓名  语文  数学  英语  物理  化学  生物\n" );
    scanf( "%d", &p->num );
    while( 1 )
    {
        if( p->num == 0 )
            break;
        cnt++;
        scanf( "%s%f%f%f%f%f%f", p->name, &( p->Chinese ).ord_scor, &( p->Math ).ord_scor, &( p->English ).ord_scor, &( p->Physics ).ord_scor, &( p->Chem ).ord_scor, &( p->Bio ).ord_scor );
        if( cnt == 1 )
        {
            head = tail = p;
        }
        else
        {
            tail->next = p;
            tail = p;
        }
        p = setup;
        scanf( "%d", &p->num );
    }
    tail->next = NULL;
    return ( head );
}

lis *alter( lis *head ) //修改学生信息
{
    float alt_num, alt_scor;
    int course;
    printf( "请输入要修改的学生学号(0代表结束): " );
    scanf( "%f", &alt_num );
    while( alt_num != 0 )
    {
        p = head;
        while( p != NULL )
        {
            if( p->num != alt_num )
                p = p->next;
            else
                break;
        }
        if( p == NULL )
        {
            printf( "输入学号有错!请重新输入(0代表结束): " );
        }
        else
        {
            printf( "请输入要修改的课程代表的编号(1-语文,2-数学,3-英语,4-物理,5-化学,6-生物,0-修改结束): " );
            scanf( "%d", &course );
            while( course > 6 || course < 0 )
            {
                printf( "输入编号有错!请重新输入编号(0代表结束): " );
                scanf( "%d", &course );
            }
            while( course != 0 )
            {
                if( course > 6 || course < 0 )
                    printf( "输入编号有错!请重新输入编号(0代表结束): " );
                else
                {
                    p = head;
                    while( p != NULL )
                    {
                        if( p->num == alt_num )
                        {
                            printf( "请输入新成绩:\n" );
                            scanf( "%f", &alt_scor );
                            switch( course )
                            {
                            case 1:
                                ( p->Chinese ).ord_scor = alt_scor;
                                break;
                            case 2:
                                ( p->Math ).ord_scor = alt_scor;
                                break;
                            case 3:
                                ( p->English ).ord_scor = alt_scor;
                                break;
                            case 4:
                                ( p->Physics ).ord_scor = alt_scor;
                                break;
                            case 5:
                                ( p->Chem ).ord_scor = alt_scor;
                                break;
                            case 6:
                                ( p->Bio ).ord_scor = alt_scor;
                                break;
                            }
                        }
                        p = p->next;
                    }
                    printf( "若继续修改该学生成绩,请输入编号(0代表结束): " );
                }
                scanf( "%d", &course );
            }
            printf( "请输入学号(0代表结束): " );
        }
        scanf( "%f", &alt_num );
    }
    return ( head );
}

lis *add( lis *head ) //增加学生信息
{
    lis *tail, *z, *q;
    q = tail = head;
    while( q != NULL )
    {
        z = tail; //z指向倒数第二个结点
        tail = q;
        q = q->next;
    }           //tail->next==NULL
    p = setup;
    printf( "请增加学生信息(学号为0无效,且结束增加):\n学号  姓名  语文  数学  英语  物理  化学  生物\n" );
    scanf( "%d%s%f%f%f%f%f%f", &p->num, p->name, &( p->Chinese ).ord_scor, &( p->Math ).ord_scor, &( p->English ).ord_scor, &( p->Physics ).ord_scor, &( p->Chem ).ord_scor, &( p->Bio ).ord_scor );
    int flag;
    while( p->num != 0 )
    {
        flag = 0;
        while( flag == 0 || flag == 1 )
        {
            q = head;
            while( q != NULL )
            {
                if( q->num == p->num ) //学号重复
                {
                    flag = 1;
                    break;
                }
                else
                    q = q->next;
            }
            if( flag == 1 )
            {
                flag = 0;
                printf( "已存在该学生,请重新输入:\n" );
                p = setup;
                scanf( "%d%s%f%f%f%f%f%f", &p->num, p->name, &( p->Chinese ).ord_scor, &( p->Math ).ord_scor, &( p->English ).ord_scor, &( p->Physics ).ord_scor, &( p->Chem ).ord_scor, &( p->Bio ).ord_scor );
            }
            else
                break;
        }
        z->next = p;
        p->next = tail;
        z = p;
        p = setup;
        scanf( "%d%s%f%f%f%f%f%f", &p->num, p->name, &( p->Chinese ).ord_scor, &( p->Math ).ord_scor, &( p->English ).ord_scor, &( p->Physics ).ord_scor, &( p->Chem ).ord_scor, &( p->Bio ).ord_scor );
    }
    return ( head );
}

lis *delet( lis *head ) //删除学生信息
{
    int del_num;
    lis *t;
    printf( "请输入要删除的成绩对应的学号(0表示删除结束):\n" );
    scanf( "%d", &del_num );
    while( del_num )
    {
        p = head;
        while( p != NULL )
        {
            if( head->num == del_num )
            {
                head = p->next;
                break;
            }
            else if( p->num == del_num )
            {
                t->next = p->next;
                break;
            }
            t = p;
            p = p->next;
        }
        if( p == NULL )
            printf( "输入学号有错!请重新输入:\n" );
        scanf( "%d", &del_num );
    }
    return ( head );
}

void search_print( lis *p )
{
    printf( "%d%7s%8.2f%10.2f%10.2f%10.2f%10.2f%10.2f\n", p->num, p->name, ( p->Chinese ).ord_scor, ( p->Math ).ord_scor, ( p->English ).ord_scor, ( p->Physics ).ord_scor, ( p->Chem ).ord_scor, ( p->Bio ).ord_scor );
}

void search( lis *head, int key ) //各种方式查询学生信息
{
    lis *q = head;
    int sear_num, sear_class, sear_course, flag1 = 0, flag2 = 0;
    char sear_name[10];
    if( key == 5 )
    {
        printf( "请输入学号:" );
        scanf( "%d", &sear_num );
    }
    else if( key == 6 )
    {
        flag1 = 1;                      //标记按班级查询
        printf( "请输入班级:" );
        scanf( "%d", &sear_class );
    }
    else if( key == 7 )
    {
        printf( "请请输入姓名:" );
        scanf( "%s", sear_name );
    }
    else if( key == 8 )
    {
        flag2 = 1;                      //标记按课程查询
        printf( "请输入课程代表的编号(1-语文,2-数学,3-英语,4-物理,5-化学,6-生物):" );
        scanf( "%d", &sear_course );
    }
    if( flag2 )                         //按课程查询
    {
        switch( sear_course )
        {
        case 1:
        {
            printf( "学号    姓名    语文\n" );
            while( q != NULL )
            {
                printf( "%d%7s%8.2f\n", q->num, q->name, ( q->Chinese ).ord_scor );
                q = q->next;
            }
        }
        break;
        case 2:
        {
            printf( "学号    姓名    数学\n" );
            while( q != NULL )
            {
                printf( "%d%7s%8.2f\n", q->num, q->name, ( q->Math ).ord_scor );
                q = q->next;
            }
        }
        break;
        case 3:
        {
            printf( "学号    姓名    英语\n" );
            while( q != NULL )
            {
                printf( "%d%7s%8.2f\n", q->num, q->name, ( q->English ).ord_scor );
                q = q->next;
            }
        }
        break;
        case 4:
        {
            printf( "学号    姓名    物理\n" );
            while( q != NULL )
            {
                printf( "%d%7s%8.2f\n", q->num, q->name, ( q->Physics ).ord_scor );
                q = q->next;
            }
        }
        break;
        case 5:
        {
            printf( "学号    姓名    化学\n" );
            while( q != NULL )
            {
                printf( "%d%7s%8.2f\n", q->num, q->name, ( q->Chem ).ord_scor );
                q = q->next;
            }
        }
        break;
        case 6:
        {
            printf( "学号    姓名    生物\n" );
            while( q != NULL )
            {
                printf( "%d%7s%8.2f\n", q->num, q->name, ( q->Bio ).ord_scor );
                q = q->next;
            }
        }
        break;
        default:
            printf( "输入错误!\n" );
        }
    }
    else
    {
        if( flag1 )                     //按班级查询
        {
            int flag3 = 0;              //标记是否有输入的班级
            while( q != NULL )
            {
                if( ( q->num ) / 100 == sear_class )
                {
                    flag3 = 1;
                    break;
                }
                q = q->next;
            }
            if( flag3 )
            {
                q = head; //q要指向头节点
                printf( "学号    姓名    语文    数学    英语    物理    化学    生物\n" );
                while( q != NULL )
                {
                    if( ( q->num ) / 100 == sear_class )
                        search_print( q );
                    q = q->next;
                }
            }
            else
                printf( "输入错误!\n" );
        }
        else                            //按学号或姓名查询
        {
            while( q != NULL )
            {
                if( q->num == sear_num )
                    break;
                if( strcmp( q->name, sear_name ) == 0 )
                    break;
                q = q->next;
            }
            if( q == NULL )
                printf( "输入错误!\n" );
            else
            {
                printf( "学号    姓名    语文    数学    英语    物理    化学    生物\n" );
                search_print( q );
            }
        }
    }
}

lis *bubble_sort( lis *head, int len, int key ) //冒泡排序
{
    lis *t = setup;
    int i = len;
    if( key == 100 ) //交换总分
    {
        while( i > 1 )
        {
            p = head;
            while( p->next != NULL )
            {
                if( p->fina_scor < ( p->next )->fina_scor )
                {
                    t->num = p->num; //交换学号
                    p->num = ( p->next )->num;
                    ( p->next )->num = t->num;
                    strcpy( t->name, p->name ); //交换姓名
                    strcpy( p->name, ( p->next )->name );
                    strcpy( ( p->next )->name, t->name );
                    t->fina_scor = p->fina_scor;
                    p->fina_scor = ( p->next )->fina_scor;
                    ( p->next )->fina_scor = t->fina_scor;
                }
                p = p->next;
            }
            i--;
        }
        return ( head );
    }
    else if( key == 1 ) //交换语分
    {
        while( i > 1 )
        {
            p = head;
            while( p->next != NULL )
            {
                if( ( p->Chinese ).ord_scor < ( ( p->next )->Chinese ).ord_scor )
                {
                    t->num = p->num; //交换学号
                    p->num = ( p->next )->num;
                    ( p->next )->num = t->num;
                    strcpy( t->name, p->name ); //交换姓名
                    strcpy( p->name, ( p->next )->name );
                    strcpy( ( p->next )->name, t->name );
                    ( t->Chinese ).ord_scor = ( p->Chinese ).ord_scor;
                    ( p->Chinese ).ord_scor = ( ( p->next )->Chinese ).ord_scor;
                    ( ( p->next )->Chinese ).ord_scor = ( t->Chinese ).ord_scor;
                }
                p = p->next;
            }
            i--;
        }
        return ( head );
    }
    else if( key == 2 ) //交换数分
    {
        while( i > 1 )
        {
            p = head;
            while( p->next != NULL )
            {
                if( ( p->Math ).ord_scor < ( ( p->next )->Math ).ord_scor )
                {
                    t->num = p->num; //交换学号
                    p->num = ( p->next )->num;
                    ( p->next )->num = t->num;
                    strcpy( t->name, p->name ); //交换姓名
                    strcpy( p->name, ( p->next )->name );
                    strcpy( ( p->next )->name, t->name );
                    ( t->Math ).ord_scor = ( p->Math ).ord_scor;
                    ( p->Math ).ord_scor = ( ( p->next )->Math ).ord_scor;
                    ( ( p->next )->Math ).ord_scor = ( t->Math ).ord_scor;
                }
                p = p->next;
            }
            i--;
        }
        return ( head );
    }
    else if( key == 3 ) //交换英分
    {
        while( i > 1 )
        {
            p = head;
            while( p->next != NULL )
            {
                if( ( p->English ).ord_scor < ( ( p->next )->English ).ord_scor )
                {
                    t->num = p->num; //交换学号
                    p->num = ( p->next )->num;
                    ( p->next )->num = t->num;
                    strcpy( t->name, p->name ); //交换姓名
                    strcpy( p->name, ( p->next )->name );
                    strcpy( ( p->next )->name, t->name );
                    ( t->English ).ord_scor = ( p->English ).ord_scor;
                    ( p->English ).ord_scor = ( ( p->next )->English ).ord_scor;
                    ( ( p->next )->English ).ord_scor = ( t->English ).ord_scor;
                }
                p = p->next;
            }
            i--;
        }
        return ( head );
    }
    else if( key == 4 ) //交换物分
    {
        while( i > 1 )
        {
            p = head;
            while( p->next != NULL )
            {
                if( ( p->Physics ).ord_scor < ( ( p->next )->Physics ).ord_scor )
                {
                    t->num = p->num; //交换学号
                    p->num = ( p->next )->num;
                    ( p->next )->num = t->num;
                    strcpy( t->name, p->name ); //交换姓名
                    strcpy( p->name, ( p->next )->name );
                    strcpy( ( p->next )->name, t->name );
                    ( t->Physics ).ord_scor = ( p->Physics ).ord_scor;
                    ( p->Physics ).ord_scor = ( ( p->next )->Physics ).ord_scor;
                    ( ( p->next )->Physics ).ord_scor = ( t->Physics ).ord_scor;
                }
                p = p->next;
            }
            i--;
        }
        return ( head );
    }
    else if( key == 5 ) //交换化分
    {
        while( i > 1 )
        {
            p = head;
            while( p->next != NULL )
            {
                if( ( p->Chem ).ord_scor < ( ( p->next )->Chem ).ord_scor )
                {
                    t->num = p->num; //交换学号
                    p->num = ( p->next )->num;
                    ( p->next )->num = t->num;
                    strcpy( t->name, p->name ); //交换姓名
                    strcpy( p->name, ( p->next )->name );
                    strcpy( ( p->next )->name, t->name );
                    ( t->Chem ).ord_scor = ( p->Chem ).ord_scor;
                    ( p->Chem ).ord_scor = ( ( p->next )->Chem ).ord_scor;
                    ( ( p->next )->Chem ).ord_scor = ( t->Chem ).ord_scor;
                }
                p = p->next;
            }
            i--;
        }
        return ( head );
    }
    else if( key == 6 ) //交换生分
    {
        while( i > 1 )
        {
            p = head;
            while( p->next != NULL )
            {
                if( ( p->Bio ).ord_scor < ( ( p->next )->Bio ).ord_scor )
                {
                    t->num = p->num; //交换学号
                    p->num = ( p->next )->num;
                    ( p->next )->num = t->num;
                    strcpy( t->name, p->name ); //交换姓名
                    strcpy( p->name, ( p->next )->name );
                    strcpy( ( p->next )->name, t->name );
                    ( t->Bio ).ord_scor = ( p->Bio ).ord_scor;
                    ( p->Bio ).ord_scor = ( ( p->next )->Bio ).ord_scor;
                    ( ( p->next )->Bio ).ord_scor = ( t->Bio ).ord_scor;
                }
                p = p->next;
            }
            i--;
        }
        return ( head );
    }
}

void final_score_sort( lis *head ) //按总分高低排序
{
    int cnt = 0, z = 100;
    p = head;
    while( p != NULL )
    {
        cnt++;
        p->fina_scor = ( p->Chinese ).ord_scor + ( p->Math ).ord_scor + ( p->English ).ord_scor + ( p->Physics ).ord_scor + ( p->Chem ).ord_scor + ( p->Bio ).ord_scor;
        p = p->next;
    }
    head = bubble_sort( head, cnt, z );
    printf( "名次    学号\t    姓名    总分\n" );
    cnt = 1;
    p = head;
    while( p != NULL )
    {
        printf( "%d\t%d\t%7s%8.2f\n", cnt++, p->num, p->name, p->fina_scor );
        p = p->next;
    }
}

void  single_course_sort( lis *head ) //单科成绩排名
{
    int select, cnt = 0;
    p = head;
    while( p != NULL )
    {
        cnt++;
        p = p->next;
    }
    printf( "请输入课程代表的编号(1-语文,2-数学,3-英语,4-物理,5-化学,6-生物):" );
    scanf( "%d", &select );
    switch( select )
    {
    case 1:
    {
        head = bubble_sort( head, cnt, select );
        printf( "名次    学号\t    姓名    语文分数\n" );
        cnt = 1;
        p = head;
        while( p != NULL )
        {
            printf( "%d\t%d\t%7s%8.2f\n", cnt++, p->num, p->name, ( p->Chinese ).ord_scor );
            p = p->next;
        }
    }
    break;
    case 2:
    {
        head = bubble_sort( head, cnt, select );
        printf( "名次    学号\t    姓名    数学分数\n" );
        cnt = 1;
        p = head;
        while( p != NULL )
        {
            printf( "%d\t%d\t%7s%8.2f\n", cnt++, p->num, p->name, ( p->Math ).ord_scor );
            p = p->next;
        }
    }
    break;
    case 3:
    {
        head = bubble_sort( head, cnt, select );
        printf( "名次    学号\t    姓名    英语分数\n" );
        cnt = 1;
        p = head;
        while( p != NULL )
        {
            printf( "%d\t%d\t%7s%8.2f\n", cnt++, p->num, p->name, ( p->English ).ord_scor );
            p = p->next;
        }
    }
    break;
    case 4:
    {
        head = bubble_sort( head, cnt, select );
        printf( "名次    学号\t    姓名    物理分数\n" );
        cnt = 1;
        p = head;
        while( p != NULL )
        {
            printf( "%d\t%d\t%7s%8.2f\n", cnt++, p->num, p->name, ( p->Physics ).ord_scor );
            p = p->next;
        }
    }
    break;
    case 5:
    {
        head = bubble_sort( head, cnt, select );
        printf( "名次    学号\t    姓名    化学分数\n" );
        cnt = 1;
        p = head;
        while( p != NULL )
        {
            printf( "%d\t%d\t%7s%8.2f\n", cnt++, p->num, p->name, ( p->Chem ).ord_scor );
            p = p->next;
        }
    }
    break;
    case 6:
    {
        head = bubble_sort( head, cnt, select );
        printf( "名次    学号\t    姓名    生物分数\n" );
        cnt = 1;
        p = head;
        while( p != NULL )
        {
            printf( "%d\t%d\t%7s%8.2f\n", cnt++, p->num, p->name, ( p->Bio ).ord_scor );
            p = p->next;
        }
    }
    break;
    default:
        printf( "输入错误!\n" );
    }
}

struct class_excel_rate
{
    int class_num, all_stu, excel_stu;
    struct class_excel_rate *next;
};

void bubble_sort_print( struct class_excel_rate *head, int lenth ) //冒泡排序并输出班级优秀率
{
    struct class_excel_rate *t = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
    int len = 0;
    float s;
    t = head;
    while( t != NULL )
    {
        len++;
        t = t->next;
    }
    while( len > 1 )
    {
        t = head;
        while( t->next != NULL )
        {
            if( ( t->next )->excel_stu / ( ( t->next )->all_stu * 0.1 ) > t->excel_stu / ( t->all_stu * 0.1 ) )
            {
                s = t->excel_stu;
                t->excel_stu = ( t->next )->excel_stu;
                ( t->next )->excel_stu = s;
                s = t->all_stu;
                t->all_stu = ( t->next )->all_stu;
                ( t->next )->all_stu = s;
            }
            t = t->next;
        }
        len--;
    }
    printf( "名次\t班级\t     总人数    优秀人数    优秀率\n" );
    int i = 1;
    t = head;
    while( t != NULL )
    {
        printf( "%d\t%d\t\t%d\t  %d\t   %.2f%%\n", i++, t->class_num, t->all_stu, t->excel_stu, t->excel_stu / ( t->all_stu * 0.1 ) * 10 );
        t = t->next;
    }
}

void select_class_find( lis *head, int len, int key ) //查询班级优秀率
{
    struct class_excel_rate *head1, *q, *r, *k; //创建新链表
    switch( key )
    {
    case 1://查询语文
    {
        p = head;
        head1 = q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
        head1->class_num = p->num / 100; //初始化头节点
        head1->all_stu = 1;
        if( ( p->Chinese ).ord_scor >= 90.0 )
            head1->excel_stu = 1;
        else
            head1->excel_stu = 0;
        p = p->next;
        while( p->next != NULL ) //先建立两个两个首、尾结点,以便其它班级的插入
        {
            if( p->num / 100 == head1->class_num ) //相同班级
            {
                head1->all_stu++;
                if( ( p->Chinese ).ord_scor >= 90.0 )
                    head1->excel_stu++;
            }
            else
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->Chinese ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                head1->next = q;
                q->next = NULL;
                break;//建立链尾结点
            }
            p = p->next;
        }
        p = p->next;
        while( p != NULL ) //检索所有剩余的班级
        {
            r = k = head1; //问题:最后一个班级检索没有被处理
            while( r != NULL ) //检索班级是否相同
            {
                if( p->num / 100 == r->class_num )
                {
                    r->all_stu++;
                    if( ( p->Chinese ).ord_scor >= 90.0 )
                        r->excel_stu++;
                    break;
                }
                else
                {
                    k = r;
                    r = r->next;
                }
            }
            if( r == NULL ) //没有相同的班级,插入新结点
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->Chinese ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                k->next = q;
                q->next = r;
            }
            p = p->next; //检索下一个处理的班级
        }
        bubble_sort_print( head1, len );
    }
    break;
    case 2://查询数学
    {
        p = head;
        head1 = q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
        head1->class_num = p->num / 100; //初始化头节点
        head1->all_stu = 1;
        if( ( p->Math ).ord_scor >= 90.0 )
            head1->excel_stu = 1;
        else
            head1->excel_stu = 0;
        p = p->next;
        while( p->next != NULL ) //先建立两个两个首、尾结点,以便其它班级的插入
        {
            if( p->num / 100 == head1->class_num ) //相同班级
            {
                head1->all_stu++;
                if( ( p->Math ).ord_scor >= 90.0 )
                    head1->excel_stu++;
            }
            else
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->Math ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                head1->next = q;
                q->next = NULL;
                break;//建立链尾结点
            }
            p = p->next;
        }
        p = p->next;
        while( p != NULL ) //检索所有剩余的班级
        {
            r = k = head1; //问题:最后一个班级检索没有被处理
            while( r != NULL ) //检索班级是否相同
            {
                if( p->num / 100 == r->class_num )
                {
                    r->all_stu++;
                    if( ( p->Math ).ord_scor >= 90.0 )
                        r->excel_stu++;
                    break;
                }
                else
                {
                    k = r;
                    r = r->next;
                }
            }
            if( r == NULL ) //没有相同的班级,插入新结点
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->Math ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                k->next = q;
                q->next = r;
            }
            p = p->next; //检索下一个处理的班级
        }
        bubble_sort_print( head1, len );
    }
    break;
    case 3://查询英语
    {
        p = head;
        head1 = q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
        head1->class_num = p->num / 100; //初始化头节点
        head1->all_stu = 1;
        if( ( p->English ).ord_scor >= 90.0 )
            head1->excel_stu = 1;
        else
            head1->excel_stu = 0;
        p = p->next;
        while( p->next != NULL ) //先建立两个两个首、尾结点,以便其它班级的插入
        {
            if( p->num / 100 == head1->class_num ) //相同班级
            {
                head1->all_stu++;
                if( ( p->English ).ord_scor >= 90.0 )
                    head1->excel_stu++;
            }
            else
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->English ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                head1->next = q;
                q->next = NULL;
                break;//建立链尾结点
            }
            p = p->next;
        }
        p = p->next;
        while( p != NULL ) //检索所有剩余的班级
        {
            r = k = head1; //问题:最后一个班级检索没有被处理
            while( r != NULL ) //检索班级是否相同
            {
                if( p->num / 100 == r->class_num )
                {
                    r->all_stu++;
                    if( ( p->English ).ord_scor >= 90.0 )
                        r->excel_stu++;
                    break;
                }
                else
                {
                    k = r;
                    r = r->next;
                }
            }
            if( r == NULL ) //没有相同的班级,插入新结点
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->English ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                k->next = q;
                q->next = r;
            }
            p = p->next; //检索下一个处理的班级
        }
        bubble_sort_print( head1, len );
    }
    break;
    case 4://查询物理
    {
        p = head;
        head1 = q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
        head1->class_num = p->num / 100; //初始化头节点
        head1->all_stu = 1;
        if( ( p->Physics ).ord_scor >= 90.0 )
            head1->excel_stu = 1;
        else
            head1->excel_stu = 0;
        p = p->next;
        while( p->next != NULL ) //先建立两个两个首、尾结点,以便其它班级的插入
        {
            if( p->num / 100 == head1->class_num ) //相同班级
            {
                head1->all_stu++;
                if( ( p->Physics ).ord_scor >= 90.0 )
                    head1->excel_stu++;
            }
            else
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->Physics ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                head1->next = q;
                q->next = NULL;
                break;//建立链尾结点
            }
            p = p->next;
        }
        p = p->next;
        while( p != NULL ) //检索所有剩余的班级
        {
            r = k = head1; //问题:最后一个班级检索没有被处理
            while( r != NULL ) //检索班级是否相同
            {
                if( p->num / 100 == r->class_num )
                {
                    r->all_stu++;
                    if( ( p->Physics ).ord_scor >= 90.0 )
                        r->excel_stu++;
                    break;
                }
                else
                {
                    k = r;
                    r = r->next;
                }
            }
            if( r == NULL ) //没有相同的班级,插入新结点
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->Physics ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                k->next = q;
                q->next = r;
            }
            p = p->next; //检索下一个处理的班级
        }
        bubble_sort_print( head1, len );
    }
    break;
    case 5://查询化学
    {
        p = head;
        head1 = q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
        head1->class_num = p->num / 100; //初始化头节点
        head1->all_stu = 1;
        if( ( p->Chem ).ord_scor >= 90.0 )
            head1->excel_stu = 1;
        else
            head1->excel_stu = 0;
        p = p->next;
        while( p->next != NULL ) //先建立两个两个首、尾结点,以便其它班级的插入
        {
            if( p->num / 100 == head1->class_num ) //相同班级
            {
                head1->all_stu++;
                if( ( p->Chem ).ord_scor >= 90.0 )
                    head1->excel_stu++;
            }
            else
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->Chem ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                head1->next = q;
                q->next = NULL;
                break;//建立链尾结点
            }
            p = p->next;
        }
        p = p->next;
        while( p != NULL ) //检索所有剩余的班级
        {
            r = k = head1; //问题:最后一个班级检索没有被处理
            while( r != NULL ) //检索班级是否相同
            {
                if( p->num / 100 == r->class_num )
                {
                    r->all_stu++;
                    if( ( p->Chem ).ord_scor >= 90.0 )
                        r->excel_stu++;
                    break;
                }
                else
                {
                    k = r;
                    r = r->next;
                }
            }
            if( r == NULL ) //没有相同的班级,插入新结点
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->Chem ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                k->next = q;
                q->next = r;
            }
            p = p->next; //检索下一个处理的班级
        }
        bubble_sort_print( head1, len );
    }
    break;
    case 6://查询生物
    {
        p = head;
        head1 = q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
        head1->class_num = p->num / 100; //初始化头节点
        head1->all_stu = 1;
        if( ( p->Bio ).ord_scor >= 90.0 )
            head1->excel_stu = 1;
        else
            head1->excel_stu = 0;
        p = p->next;
        while( p->next != NULL ) //先建立两个两个首、尾结点,以便其它班级的插入
        {
            if( p->num / 100 == head1->class_num ) //相同班级
            {
                head1->all_stu++;
                if( ( p->Bio ).ord_scor >= 90.0 )
                    head1->excel_stu++;
            }
            else
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->Bio ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                head1->next = q;
                q->next = NULL;
                break;//建立链尾结点
            }
            p = p->next;
        }
        p = p->next;
        while( p != NULL ) //检索所有剩余的班级
        {
            r = k = head1; //问题:最后一个班级检索没有被处理
            while( r != NULL ) //检索班级是否相同
            {
                if( p->num / 100 == r->class_num )
                {
                    r->all_stu++;
                    if( ( p->Bio ).ord_scor >= 90.0 )
                        r->excel_stu++;
                    break;
                }
                else
                {
                    k = r;
                    r = r->next;
                }
            }
            if( r == NULL ) //没有相同的班级,插入新结点
            {
                q = ( struct class_excel_rate * )malloc( sizeof( struct class_excel_rate ) );
                q->class_num = p->num / 100;
                q->all_stu = 1;
                if( ( p->Bio ).ord_scor >= 90.0 )
                    q->excel_stu = 1;
                else
                    q->excel_stu = 0;
                k->next = q;
                q->next = r;
            }
            p = p->next; //检索下一个处理的班级
        }
        bubble_sort_print( head1, len );
    }
    break;
    }
}

void select_course_find( lis *head ) //选择查询课程优秀率
{
    int select, cnt = 0;
    p = head;
    while( p != NULL )
    {
        cnt++;
        p = p->next;
    }
    printf( "请输入课程代表的编号(1-语文,2-数学,3-英语,4-物理,5-化学,6-生物):" );
    scanf( "%d", &select );
    switch( select )
    {
    case 1:
        select_class_find( head, cnt, select );
        break;
    case 2:
        select_class_find( head, cnt, select );
        break;
    case 3:
        select_class_find( head, cnt, select );
        break;
    case 4:
        select_class_find( head, cnt, select );
        break;
    case 5:
        select_class_find( head, cnt, select );
        break;
    case 6:
        select_class_find( head, cnt, select );
        break;
    default:
        printf( "输入错误!\n" );
    }
}

void output( lis *head ) //输出学生信息
{
    p = setup;
    p = head;
    printf( "学号    姓名    语文      数学      英语      物理      化学      生物\n" );
    while( p != NULL )
    {
        printf( "%d%7s%8.2f%10.2f%10.2f%10.2f%10.2f%10.2f\n", p->num, p->name, ( p->Chinese ).ord_scor, ( p->Math ).ord_scor, ( p->English ).ord_scor, ( p->Physics ).ord_scor, ( p->Chem ).ord_scor, ( p->Bio ).ord_scor );
        p = p->next;
    }
}

void print()
{
    printf( "\t\t-------学生成绩管理系统-------\n" );
    printf( "\t\t\t0、浏览学生信息\n\t\t\t1、输入学生信息\n\t\t\t2、增加学生信息\n\t\t\t3、修改学生信息\n\t\t\t4、删除学生信息\n\t\t\t5、按学号查询\n" );
    printf( "\t\t\t6、按班级查询\n\t\t\t7、按姓名查询\n\t\t\t8、按课堂名称查询\n\t\t\t9、按总分高低排序\n\t\t\t10、单科成绩排名\n\t\t\t11、查询班级优秀率\n\t\t\t12、清屏\n\t\t\t13、退出系统\n" );
    printf( "\t\t------------------------------\n" );
    printf( "\n>>请输入要实现功能前的序号:  " );
}

int main()
{
    int fun;
    lis *student;
    print();
    while( 1 )
    {
        scanf( "%d", &fun );
        switch( fun )
        {
        case 0:
            output( student );
            break;
        case 1:
            student = input();
            break;
        case 2:
            student = add( student );
            break;
        case 3:
            student = alter( student );
            break;
        case 4:
            student = delet( student );
            break;
        case 5:
        case 6:
        case 7:
        case 8:
            search( student, fun );
            break;
        case 9:
            final_score_sort( student );
            break;
        case 10:
            single_course_sort( student );
            break;
        case 11:
            select_course_find( student );
            break;
        case 12: {
            system( "cls" );
            print();
        }
        }
        if( fun == 1 )
        {
            system( "cls" );
            print();
        }
        else if( fun == 13 )
            break;
        else if( fun > 13 )
            printf( "\n\t**输入错误!\n>>请输入要实现功能前的序号: " );
        else if( fun != 12 )
            printf( "\n>>请输入要实现功能前的序号: " );
    }
    return 0;
}

/*测试数据
150901 james  100  99    94   89.9    93    95
130118 bryant 93   98    75   78.9    99.2  97.1
161226 lu     85   99    78   79      66    66.9
130821 jordon 99   100   98.1 90.6    91    89.9
150928 antony 98   97.4  91.9 89      78    79.4
161127 durant 100  98    93   82      97    80
161222 love   90   89    90   91.2    93    82.7
130156 duncan 99   98    91   82.5    89    78
160703 paul   90   91.5  98   89      87.9  80
150433 wade   93   93.4  95   91      89    80.9
161316 irving 96   89    91.8 95      91    98.8
161205 harden 89   88    93   95      96.7  99
161305 curry  89.9 92    89   46.9    39    100
160739 bosh   91.5 78    98   69.9    89    85
0
*/

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/127355.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 关于SHFileOperation「建议收藏」

    关于SHFileOperation「建议收藏」
    CStringstr=”f://11″;
    FileOp.pFrom = (LPCTSTR)str;
     
    执行不成功,翻了下msdn
    ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WIN32COM.v10.en/shellcc/platform/shell/reference/structures/shfileopstruct.htm
     pFromAddressofabuffertospecifyon

  • 轻松搞懂Word2vec / FastText+BiLSTM、TextCNN、CNN+BiLSTM、BiLSTM+Attention实现中英文情感分类

    轻松搞懂Word2vec / FastText+BiLSTM、TextCNN、CNN+BiLSTM、BiLSTM+Attention实现中英文情感分类前言讲道理,这篇博客应该可以帮助很多只有一点点NLP的朋友,在较短的时间内了解文本分类的整个过程并用代码复现整个流程。事先说明,这里大家先不要过分要求自己去理解整个模型的原理,先搞清楚整个实现流程,体验一下敲代码并成功应用的快感。实现流程找数据集首先第一步,就是要找好数据集,没有数据集模型怎么学习,怎么涨知识。那这里呢,我们采用的情感数据集是weibo_senti_100k数据集,一共有119988条带情感标注的新浪微博评论,其中正负向评论均为59994条,非常平衡的一个数据集。其中lab.

  • JSF标签_img标签详解

    JSF标签_img标签详解1.JSF入门藉由以下的几个主题,可以大致了解JSF的轮廓与特性,我们来看看网页设计人员与应用程序设计人员各负责什么。1.1简介JSFWeb应用程序的开发与传统的单机程序开发在本质上存在着太多的差异,

  • 鸢尾花数据集knn算法可视化(在R中找到鸢尾花数据)

    kNN处理鸢尾花数据集kNN(KNearestNeighbor)算法是机器学习中最基础入门,也是最常用的算法之一,可以解决大多数分类与回归问题。这里以鸢尾花数据集为例,讨论分类问题中的kNN的思想。鸢尾花数据集内包含3类共150条记录,每类各50个数据,每条记录都有4项特征:花萼长度(sepallength)、花萼宽度(sepalwidth)、花瓣长度(petal…

  • 如何用vscode进行前端开发 知乎_vscode单步调试

    如何用vscode进行前端开发 知乎_vscode单步调试如何用VsCode进行Debug本文以Mac系统,C++程序为例,进行Debug操作安装插件不同的语言需要安装的debug插件不一样,如下Debug页面VsCode的Debug页面如下配置Debug环境点击左侧的Debug图标,默认情况下,展示的是配置提示点击图中的【运行和调试】,选择【GDB/LLDB】环境,之后在下拉列表选择【默认配置】,系统自动创建launch.json文件,用于记录debug的配置信息,其中最主要的是配置调试的程序,program字段,选择要debug运行的

    2022年10月15日
  • cocos2dx触屏响应(单点触摸)CCTouchBegan,CCTouchMove,CCTouchEnd

    cocos2dx触屏响应(单点触摸)CCTouchBegan,CCTouchMove,CCTouchEnd

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号