第12章实验1:学生成绩管理系统V5.0(c语言)

本文介绍了如何使用C语言实现一个学生成绩管理系统V5.0,包括录入、计算、排序和统计等功能。系统允许用户输入学生人数和课程数,录入学号、姓名及各科成绩,可以计算每门课程和每个学生的总分、平均分,按成绩高低、学号和姓名排序,以及按学号和姓名搜索学生信息。此外,系统还能进行统计分析,如按成绩区间统计学生比例。

第12章实验1:学生成绩管理系统V5.0

某班有最多不超过30人(具体人数由键盘输入)参加期末考试,最多不超过6门(具体门数由键盘输入)。参考学生成绩管理系统V4.0,定义结构体类型,用结构体数组作函数参数,编程实现如下菜单驱动的学生成绩管理系统:
(1)录入每个学生的学号、姓名和各科考试成绩;
(2)计算每门课程的总分和平均分;
(3)计算每个学生的总分和平均分;
(4)按每个学生的总分由高到低排出名次表;
(5)按每个学生的总分由低到高排出名次表;
(6)按学号由小到大排出成绩表;
(7)按姓名的字典顺序排出成绩表;
(8)按学号查询学生排名及其考试成绩;
(9)按姓名查询学生排名及其考试成绩;
(10)按优秀(90100)、良好(8089)、中等(7079)、及格(6069)、不及格(0~59)5个类别,对每门课程分别统计每个类别的人数以及所占的百分比;
(11)输出每个学生的学号、姓名、各科考试成绩,以及每门课程的总分和平均分。

要求程序运行后先显示如下菜单,并提示用户输入选项:
Management for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit
Please Input your choice:
然后,根据用户输入的选项执行相应的操作。

请按照下面的定义及函数原型编程

代码在最后面!!!

#define MAX_LEN 10 /* 字符串最大长度 /
#define STU_NUM 30 /
最多的学生人数 /
#define COURSE_NUM 6 /
最多的考试科目数 / typedef struct student {
long num; /
每个学生的学号 /
char name[MAX_LEN]; /
每个学生的姓名 /
float score[COURSE_NUM]; /
每个学生COURSE_NUM门功课的成绩 /
float sum; /
每个学生的总成绩 /
float aver; /
每个学生的平均成绩 */ }STU; int Menu(void); void ReadScore(STU stu[], int n, int m); void
AverSumofEveryStudent(STU stu[], int n, int m); void
AverSumofEveryCourse(STU stu[], int n, int m); void SortbyScore(STU
stu[],int n,int m,int (*compare)(float a,float b)); int
Ascending(float a, float b); int Descending(float a, float b); void
SwapFloat(float *x, float *y); void SwapLong(long *x, long *y); void
SwapChar(char x[], char y[]); void AsSortbyNum(STU stu[], int n, int
m); void SortbyName(STU stu[], int n, int m); void SearchbyNum(STU
stu[], int n, int m); void SearchbyName(STU stu[], int n, int m);
void StatisticAnalysis(STU stu[], int n, int m); void PrintScore(STU
stu[], int n, int m);

下面是程序运行示例: Input student number(n<30): 6↙ Management for Students’
scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 1↙ Input course number(m<=6): 3↙ Input student’s ID, name and score: 11003001↙ lisi↙ 87↙ 82↙ 89↙
11003005↙ heli↙ 98↙ 92↙ 90↙ 11003003↙ ludi↙ 75↙ 78↙ 80↙ 11003002↙
dumo↙ 48↙ 50↙ 67↙ 11003004↙ zuma↙ 65↙ 69↙ 72↙ 11003006↙ suyu↙ 100↙ 95↙
94↙ Management for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 2↙ course 1:sum=473,aver=79 course 2:sum=466,aver=78 course 3:sum=492,aver=82 Management for Students’
scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 3↙ student 1: sum=258,aver=86 student 2: sum=280,aver=93 student 3: sum=233,aver=78 student 4:
sum=165,aver=55 student 5: sum=206,aver=69 student 6: sum=289,aver=96
Management for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 4↙ Sort in descending order by score: 11003006 suyu 100 95 94 289 96 11003005
heli 98 92 90 280 93 11003001 lisi 87
82 89 258 86 11003003 ludi 75 78 80
233 78 11003004 zuma 65 69 72 206 69
11003002 dumo 48 50 67 165 55 Management
for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 5↙ Sort in ascending order by score: 11003002 dumo 48 50 67 165 55 11003004
zuma 65 69 72 206 69 11003003 ludi 75
78 80 233 78 11003001 lisi 87 82 89
258 86 11003005 heli 98 92 90 280 93
11003006 suyu 100 95 94 289 96 Management
for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 6↙ Sort in ascending order by number: 11003001 lisi 87 82 89 258 86 11003002
dumo 48 50 67 165 55 11003003 ludi 75
78 80 233 78 11003004 zuma 65 69 72
206 69 11003005 heli 98 92 90 280 93
11003006 suyu 100 95 94 289 96 Management
for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 7↙ Sort in dictionary order by name: 11003002 dumo 48 50 67 165 55 11003005
heli 98 92 90 280 93 11003001 lisi 87
82 89 258 86 11003003 ludi 75 78 80
233 78 11003006 suyu 100 95 94 289 96
11003004 zuma 65 69 72 206 69 Management
for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 8↙ Input the number you want to search: 11003007↙ Not found! Management for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 8↙ Input the number you want to search: 11003004↙ 11003004 zuma 65 69 72 206
69 Management for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 9↙ Input the name you want to search: lili↙ Not found! Management for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 9↙ Input the name you want to search: lisi↙ 11003001 lisi 87 82 89 258 86
Management for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 10↙ For course 1: <60 1 16.67% 60-69 1 16.67% 70-79 1 16.67% 80-89 1 16.67% 90-99 1 16.67% 100 1 16.67% For course 2: <60 1 16.67% 60-69 1 16.67% 70-79 1 16.67% 80-89 1
16.67% 90-99 2 33.33% 100 0 0.00% For course 3: <60 0 0.00% 60-69 1 16.67% 70-79 1 16.67% 80-89 2
33.33% 90-99 2 33.33% 100 0 0.00% Management for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 11↙ 11003002 dumo 48 50 67 165 55 11003005 heli 98 92 90
280 93 11003001 lisi 87 82 89 258 86
11003003 ludi 75 78 80 233 78 11003006
suyu 100 95 94 289 96 11003004 zuma 65
69 72 206 69 Management for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 12↙ Input error! Management for Students’ scores
1.Input record
2.Caculate total and average score of every course
3.Caculate total and average score of every student
4.Sort in descending order by score
5.Sort in ascending order by score
6.Sort in ascending order by number
7.Sort in dictionary order by name
8.Search by number
9.Search by name
10.Statistic analysis
11.List record
0.Exit Please Input your choice: 0↙ End of program!

输入格式: ( 1 )录入学生的人数:
**要求输入数据格式为:"%d"
**提示信息为:“Input student number(n<30):\n” ( 2 )录入课程数:
**要求输入数据格式为:"%d"
**提示信息为:“Input course number(m<=%d):\n” ( 3 )录入每个学生的学号、姓名和考试成绩:
**要求学号、姓名的输入数据格式为:"%ld%s"
**要求考试成绩的输入数据格式为:"%f"
**提示信息为:“Input student’s ID, name and score:\n”

输出格式: 计算每门课程的总分和平均分:
**要求输出总分与平均分格式为:“course %d:sum=%.0f,aver=%.0f\n” 计算每个学生的总分和平均分:
**要求输出总分与平均分格式为:“student %d: sum=%.0f,aver=%.0f\n” 按成绩由高到低排出名次表:
**要求学号、姓名的输出格式为:"%ld\t%s\t"
**要求成绩的输出格式为:"%.0f\t"
**要求总分及平均分的输出格式为:"%.0f\t%.0f\n"
**提示信息为:“Sort in descending order by score:\n” 按成绩由低到高排出名次表:
**要求学号、姓名的输出格式为:"%ld\t%s\t"
**要求成绩的输出格式为:"%.0f\t"
**要求总分及平均分的输出格式为:"%.0f\t%.0f\n"
**提示信息为:“Sort in ascending order by score:\n” 按学号由小到大排出成绩表:
**要求学号、姓名的输出格式为:"%ld\t%s\t"
**要求成绩的输出格式为:"%.0f\t"
**要求总分及平均分的输出格式为:"%.0f\t%.0f\n"
**提示信息为:“Sort in ascending order by number:\n” 按姓名的字典顺序排出成绩表
**要求学号、姓名的输出格式为:"%ld\t%s\t"
**要求成绩的输出格式为:"%.0f\t"
**要求总分及平均分的输出格式为:"%.0f\t%.0f\n"
**提示信息为:“Sort in dictionary order by name:\n” 按学号查询学生排名及其考试成绩:
**如果未查到此学号的学生,提示信息为:“Not found!\n”;
**如果查询到该学生
# 要求学号、姓名的输出格式为:"%ld\t%s\t"
# 要求成绩的输出格式为:"%.0f\t"
# 要求总分及平均分的输出格式为:"%.0f\t%.0f\n"
**提示信息为:“Input the number you want to search:\n” 按姓名查询学生排名及其考试成绩;
**如果未查到此学号的学生,提示信息为:“Not found!\n”;
**如果查询到该学生
# 要求学号、姓名的输出格式为:"%ld\t%s\t"
# 要求成绩的输出格式为:"%.0f\t"
# 要求总分及平均分的输出格式为:"%.0f\t%.0f\n"
**提示信息为:“Input the name you want to search:\n” 按优秀(90100)、良好(8089)、中等(7079)、及格(6069)、不及格(0~59)5个类别,统计每个类别的人数以及所占的百分比:
**成绩<60输出提示格式为:"<60\t%d\t%.2f%%\n";
**成绩=100输出格式为:"%d\t%d\t%.2f%%\n";
**其他要求输出百分比格式为:"%d-%d\t%d\t%.2f%%\n"
**提示信息为: “For course %d:\n” 输出每个学生的学号、姓名、考试成绩,以及课程总分和平均分
**要求学号、姓名的输出格式为:"%ld\t%s\t"
**要求成绩的输出格式为:"%.0f\t"
**要求总分及平均分的输出格式为:"%.0f\t%.0f\n" 选择退出(菜单项0)
**提示信息:“End of program!” 菜单项选择错误(不在0-11之间)
**提示信息:“Input error!\n”

#include  <stdio.h>
#include  <stdlib.h>
#include  <string.h>
#define   MAX_LEN  10                       /* 字符串最大长度 */
#define   STU_NUM 30                       /* 最多的学生人数 */
#define   COURSE_NUM 6                     /* 最多的考试科目数 */
typedef struct student
{		 		 	     
    long num;                       /* 每个学生的学号 */
    char name[MAX_LEN];             /* 每个学生的姓名 */
    float score[COURSE_NUM];        /* 每个学生COURSE_NUM门功课的成绩 */
    float sum;                           /* 每个学生的总成绩 */
    float aver;                      /* 每个学生的平均成绩 */
}		 		 	      STU;
int   Menu(void);
void  ReadScore(STU stu[], int n, int m);
void  AverSumofEveryStudent(STU stu[], int n, int m);
void  AverSumofEveryCourse(STU stu[], int n, int m);
void  SortbyScore(STU stu[], int n, int m, int (*compare)(float a, float b));
int   Ascending(float a, float b);
int   Descending(float a, float b);
void  SwapFloat(float *x, float *y);
void  SwapLong(long *x, long *y);
void  SwapChar(char x[], char y[]);
void  AsSortbyNum(STU stu[], int n, int m);
void  SortbyName(STU stu[], int n, int m);
void  SearchbyNum(STU stu[], int n, int m);
void  SearchbyName(STU stu[], int n, int m);
void  StatisticAnalysis(STU stu[], int n, int m);
void  PrintScore(STU stu[], int n, int m);
int main()
{		 		 	     
    char  ch;
    int   n = 0, m = 0;  /* 学生人数为n,课程门数为m */
    STU   stu[STU_NUM];
    printf("Input student number(n<=30):\n", STU_NUM);
    scanf("%d", &n);
    while (1)
    {		 		 	     
        ch = Menu();                        /* 显示菜单,并读取用户输入 */
        switch (ch)
        {		 		 	     
        case 1:
            printf("Input course number(m<=%d):\n", COURSE_NUM);
            scanf("%d", &m);
            ReadScore(stu, n, m);
            break;
        case 2:
            AverSumofEveryCourse(stu, n, m);
            break;
        case 3:
            AverSumofEveryStudent(stu, n, m);
            break;
        case 4:
            SortbyScore(stu, n, m, Descending);
            printf("Sort in descending order by score:\n");
            PrintScore(stu, n, m);
            break;
        case 5:
            SortbyScore(stu, n, m, Ascending);
            printf("Sort in ascending order by score:\n");
            PrintScore(stu, n, m);
            break;
        case 6:
            AsSortbyNum(stu, n, m);
            printf("Sort in ascending order by number:\n");
            PrintScore(stu, n, m);
            break;
        case 7:
            SortbyName(stu, n, m);
            printf("Sort in dictionary order by name:\n");
            PrintScore(stu, n, m);
            break;
        case 8:
            SearchbyNum(stu, n, m);
            break;
        case 9:
            SearchbyName(stu, n, m);
            break;
        case 10:
            StatisticAnalysis(stu, n, m);
            break;
        case 11:
            PrintScore(stu, n, m);
            break;
        case 0:
            printf("End of program!");
            exit(0);
        default:
            printf("Input error!\n");
        }
    }
    return 0;
}		 		 	     
/*  函数功能:显示菜单并获得用户键盘输入的选项 */
int Menu(void)
{		 		 	     
    int itemSelected;
    printf("Management for Students' scores\n");
    printf("1.Input record\n");
    printf("2.Caculate total and average score of every course\n");
    printf("3.Caculate total and average score of every student\n");
    printf("4.Sort in descending order by score\n");
    printf("5.Sort in ascending order by score\n");
    printf("6.Sort in ascending order by number\n");
    printf("7.Sort in dictionary order by name\n");
    printf("8.Search by number\n");
    printf("9.Search by name\n");
    printf("10.Statistic analysis\n");
    printf("11.List record\n");
    printf("0.Exit\n");
    printf("Please Input your choice:\n");
    scanf("%d", &itemSelected);     /* 读入用户输入 */
    return itemSelected;
}		 		 	     
/* 函数功能:输入n个学生的m门课成绩 */
void ReadScore(STU stu[], int n, int m)
{		 		 	     
    int i, j;
    printf("Input student's ID, name and score:\n");
    for (i = 0; i < n; i++)
    {		 		 	     
        scanf("%ld%s", &stu[i].num, stu[i].name);
        for (j = 0; j < m; j++)
        {		 		 	     
            scanf("%f", &stu[i].score[j]);
        }
    }
}		 		 	     
/* 函数功能:计算每个学生各门课程的总分和平均分 */
void AverSumofEveryStudent(STU stu[], int n, int m)
{		 		 	     
    int i, j;
    for (i = 0; i < n; i++)
    {		 		 	     
        stu[i].sum = 0;
        for (j = 0; j < m; j++)
        {		 		 	     
            stu[i].sum = stu[i].sum + stu[i].score[j];
        }
        stu[i].aver = m > 0 ? stu[i].sum / m : -1;
        printf("student %d: sum=%.0f,aver=%.0f\n",
               i + 1, stu[i].sum, stu[i].aver);
    }
}		 		 	     
/* 函数功能:计算每门课程的总分和平均分 */
void AverSumofEveryCourse(STU stu[], int n, int m)
{		 		 	     
    int    i, j;
    float sum[COURSE_NUM], aver[COURSE_NUM];
    for (j = 0; j < m; j++)
    {		 		 	     
        sum[j] = 0;
        for (i = 0; i < n; i++)
        {		 		 	     
            sum[j] = sum[j] + stu[i].score[j];
        }
        aver[j] = n > 0 ? sum[j] / n : -1;
        printf("course %d:sum=%.0f,aver=%.0f\n", j + 1, sum[j], aver[j]);
    }
}		 		 	     
/* 函数功能:按选择法将数组sum的元素值排序 */
void SortbyScore(STU stu[], int n, int m, int (*compare)(float a, float b))
{		 		 	     
    int  i, j, k, t;
    for (i = 0; i < n - 1; i++)
    {		 		 	     
        k = i;
        for (j = i + 1; j < n; j++)
        {		 		 	     
            if ((*compare)(stu[j].sum, stu[k].sum))  k = j;
        }
        if (k != i)
        {		 		 	     
            for (t = 0; t < m; t++)         /* 交换m门课程的成绩 */
            {		 		 	     
                SwapFloat(&stu[k].score[t], &stu[i].score[t]);
            }
            SwapFloat(&stu[k].sum, &stu[i].sum);    /* 交换总分 */
            SwapFloat(&stu[k].aver, &stu[i].aver); /* 交换平均分 */
            SwapLong(&stu[k].num, &stu[i].num);     /* 交换学号 */
            SwapChar(stu[k].name, stu[i].name);     /* 交换姓名 */
        }
    }
}		 		 	     
/* 使数据按升序排序 */
int Ascending(float a, float b)
{		 		 	     
    return a < b;     /* 这样比较决定了按升序排序,如果a<b,则交换 */
}		 		 	     
/* 使数据按降序排序 */
int Descending(float a, float b)
{		 		 	     
    return a > b;    /* 这样比较决定了按降序排序,如果a>b,则交换 */
}		 		 	     
/* 交换两个单精度浮点型数据 */
void  SwapFloat(float *x, float *y)
{		 		 	     
    float  temp;
    temp = *x;
    *x = *y;
    *y = temp;
}		 		 	     
/* 交换两个长整型数据 */
void  SwapLong(long *x, long *y)
{		 		 	     
    long   temp;
    temp = *x;
    *x = *y;
    *y = temp;
}		 		 	     
/* 交换两个字符串 */
void  SwapChar(char x[], char y[])
{		 		 	     
    char temp[MAX_LEN];
    strcpy(temp, x);
    strcpy(x, y);
    strcpy(y, temp);
}		 		 	     
/* 函数功能:按选择法将数组num的元素值按从低到高排序 */
void AsSortbyNum(STU stu[], int n, int m)
{		 		 	     
    int  i, j, k, t;
    for (i = 0; i < n - 1; i++)
    {		 		 	     
        k = i;
        for (j = i + 1; j < n; j++)
        {		 		 	     
            if (stu[j].num < stu[k].num) k = j;
        }
        if (k != i)
        {		 		 	     
            for (t = 0; t < m; t++)        /* 交换m门课程的成绩 */
            {		 		 	     
                SwapFloat(&stu[k].score[t], &stu[i].score[t]);
            }
            SwapFloat(&stu[k].sum, &stu[i].sum);    /* 交换总分 */
            SwapFloat(&stu[k].aver, &stu[i].aver); /* 交换平均分 */
            SwapLong(&stu[k].num, &stu[i].num);     /* 交换学号 */
            SwapChar(stu[k].name, stu[i].name);     /* 交换姓名 */
        }
    }
}		 		 	     
/* 函数功能:交换法实现字符串按字典顺序排序 */
void SortbyName(STU stu[], int n, int m)
{		 		 	     
    int  i, j, t;
    for (i = 0; i < n - 1; i++)
    {		 		 	     
        for (j = i + 1; j < n; j++)
        {		 		 	     
            if (strcmp(stu[j].name, stu[i].name) < 0)
            {		 		 	     
                for (t = 0; t < m; t++) /* 交换m门课程的成绩 */
                {		 		 	     
                    SwapFloat(&stu[i].score[t], &stu[j].score[t]);
                }
                SwapFloat(&stu[i].sum, &stu[j].sum);    /* 交换总分 */
                SwapFloat(&stu[i].aver, &stu[j].aver); /* 交换平均分 */
                SwapLong(&stu[i].num, &stu[j].num);     /* 交换学号 */
                SwapChar(stu[i].name, stu[j].name);     /* 交换姓名 */
            }
        }
    }
}		 		 	     
/* 函数功能:按学号查找学生成绩并显示查找结果 */
void SearchbyNum(STU stu[], int n, int m)
{		 		 	     
    long  number;
    int   i, j;
    printf("Input the number you want to search:\n");
    scanf("%ld", &number);
    for (i = 0; i < n; i++)
    {		 		 	     
        if (stu[i].num == number)
        {		 		 	     
            printf("%ld\t%s\t", stu[i].num, stu[i].name);
            for (j = 0; j < m; j++)
            {		 		 	     
                printf("%.0f\t", stu[i].score[j]);
            }
            printf("%.0f\t%.0f\n", stu[i].sum, stu[i].aver);
            return;
        }
    }
    printf("Not found!\n");
}		 		 	     
/* 函数功能:按姓名的字典顺序排出成绩表 */
void SearchbyName(STU stu[], int n, int m)
{		 		 	     
    char x[MAX_LEN];
    int  i, j;
    printf("Input the name you want to search:\n");
    scanf("%s", x);
    for (i = 0; i < n; i++)
    {		 		 	     
        if (strcmp(stu[i].name, x) == 0)
        {		 		 	     
            printf("%ld\t%s\t", stu[i].num, stu[i].name);
            for (j = 0; j < m; j++)
            {		 		 	     
                printf("%.0f\t", stu[i].score[j]);
            }
            printf("%.0f\t%.0f\n", stu[i].sum, stu[i].aver);
            return;
        }
    }
    printf("Not found!\n");
}		 		 	     
/* 函数功能:统计各分数段的学生人数及所占的百分比 */
void StatisticAnalysis(STU stu[], int n, int m)
{		 		 	     
    int  i, j, total, t[6];
    for (j = 0; j < m; j++)
    {		 		 	     
        printf("For course %d:\n", j + 1);
        memset(t, 0, sizeof(t));    /* 将数组t的全部元素初始化为0 */
        for (i = 0; i < n; i++)
        {		 		 	     
            if (stu[i].score[j] >= 0 && stu[i].score[j] < 60) t[0]++;
            else if (stu[i].score[j] < 70)                    t[1]++;
            else if (stu[i].score[j] < 80)                   t[2]++;
            else if (stu[i].score[j] < 90)                   t[3]++;
            else if (stu[i].score[j] < 100)                   t[4]++;
            else if (stu[i].score[j] == 100)                t[5]++;
        }
        for (total = 0, i = 0; i <= 5; i++)
        {		 		 	     
            total = total + t[i];
        }
        for (i = 0; i <= 5; i++)
        {		 		 	     
            if (i == 0) printf("<60\t%d\t%.2f%%\n", t[i], (float)t[i] / n * 100);
            else if (i == 5) printf("%d\t%d\t%.2f%%\n",
                                        (i + 5) * 10, t[i], (float)t[i] / n * 100);
            else    printf("%d-%d\t%d\t%.2f%%\n",
                               (i + 5) * 10, (i + 5) * 10 + 9, t[i], (float)t[i] / n * 100);
        }
    }
}		 		 	     
/* 函数功能: 打印学生成绩 */
void PrintScore(STU stu[], int n, int m)
{		 		 	     
    int i, j;
    for (i = 0; i < n; i++)
    {		 		 	     
        printf("%ld\t%s\t", stu[i].num, stu[i].name);
        for (j = 0; j < m; j++)
        {		 		 	     
            printf("%.0f\t", stu[i].score[j]);
        }
        printf("%.0f\t%.0f\n", stu[i].sum, stu[i].aver);
    }
}

赞

学生成绩管理系统V1.0 【教学要求】 通过实验学生能够掌握一维数组做函数数,排序、查找、统计分析等常用算法,模块化设计程序设计以及增量测试方法。 【教学重点】 1.掌握一维数组的定义、初始化和引用。 2.掌握向函数传递一维数组。 3.掌握常用的排序和查找算法。 【教学难点】 1.掌握向函数传递一维数组。 2.掌握常用的排序和查找算法。 【主要仪器设备及材料】 安装有C语言开发环境的电脑 【主要内容】 学生成绩管理系统V1.0 某班有最多超过30具体人数键盘输入加某门课程的考试,用一维数组作函数数编程实现如下学生成绩管理: (1)录入每个学生的学号和考试成绩; (2)计算课程的总分和平均分; (3)按成绩由高到低排出名次表; (4)按学号由小到大排出成绩表; (5)按学号查询学生排名及其考试成绩; (6)按优秀(90~100)、良好(80~89)、中等(70~79)、及格(60~69)、及格(0~59)5个类别,统计每个类别的人数以及所占的百分比; (7)输出每个学生的学号、考试成绩、课程总分和平均分。 实验目的:熟悉一维数组做函数数,排序、查找、统计分析等常用算法,模块化设计程序设计以及增量测试方法。 【思考题】如果要求程序运行后先显示如下菜单,并提示用户输入选项: 1.Input record 2.Caculate total and average score of course 3.Sort in descending order by score 4. Sort in ascending order by number 5.Search by number 6.Statistic analysis 7.List record 0.Exit Please enter your choice: 然后根据用户输入的选项执行相应的操作,那么程序应该如何修改呢? 学生成绩管理系统V2.0 【教学要求】 掌握函数指针做函数数、模块化程序设计以及增量测试方法。 【教学重点】 1.函数指针做函数数 2.模块化程序设计以及增量测试方法。 【教学难点】 1.函数指针做函数数 2.模块化程序设计以及增量测试方法。 【主要仪器设备及材料】 安装有C语言开发环境的电脑 【主要内容】 学生成绩管理系统V2.0 某班有最多超过30具体人数键盘输入加某门课程的考试,用一维数组和函数指针作函数数,编程实现如下菜单驱动的学生成绩管理: (1)录入每个学生的学号和考试成绩; (2)计算课程的总分和平均分; (3)按成绩由高到低排出名次表; (4)按成绩由低到高排出名次表; (5)按学号由小到大排出成绩表; (6)按学号查询学生排名及其考试成绩; (7)按优秀(90~100)、良好(80~89)、中等(70~79)、及格(60~69)、及格(0~59)5个类别,统计每个类别的人数以及所占的百分比; (8)输出每个学生的学号、考试成绩、课程总分和平均分。 要求程序运行后先显示如下菜单,并提示用户输入选项: 1.Input record 2.Caculate total and average score of course 3.Sort in descending order by score 4. Sort in ascending order by number 5.Search by number 6.Statistic analysis 7.List record 0.Exit Please enter your choice: 然后,根据用户输入的选项执行相应的操作。 实验目的:在第8实验学生成绩管理系统V1.0”的基础上,通过增加任务要求,熟悉函数指针作函数数、模块化设计程序设计以及增量测试方法。 学生成绩管理系统V3.0 【教学要求】 掌握二维字符数组作函数数,字符串处理操作、模块化程序设计以及增量测试方法。 【教学重点】 1.二维字符数组作函数数 2.字符串处理操作 【教学难点】 1.二维字符数组作函数数 2.字符串处理操作 【主要仪器设备及材料】 安装有C语言开发环境的电脑 【主要内容】 学生成绩管理系统V3.0 某班有最多超过30具体人数键盘输入加某门课程的考试,用二维字符数组作函数数,编程实现如下菜单驱动的学生成绩管理: (1)录入每个学生的学号、姓名和考试成绩; (2)计算课程的总分和平均分; (3)按成绩由低到高排出名次表; (4)按成绩由低到高排出名次表; (5)按学号由小到大排出成绩表; (6)按姓名的字典顺序排出成绩表; (7)按学号查询学生排名及其考试成绩; (8)按姓名查询学生排名及其考试成绩; (9)按优秀(90~100)、良好(80~89)、中等(70~79)、及格(60~69)、及格(0~59)5个类别,统计每个类别的人数以及所占的百分比; (10)输出每个学生的学号、考试成绩、课程总分和平均分。 要求程序运行后先显示如下菜单,并提示用户输入选项: 1.Input record 2.Caculate total and average score of course 3.Sort in descending order by score 4.Sort in ascending order by number 5. Sort in ascending order by score 6.Sort in dictionary by name 7.Search by number 8.Search by name 9.Statistic analysis 10.List record 0.Exit Please enter your choice: 然后,根据用户输入的选项执行相应的操作。 实验目的:在第9实验学生成绩管理系统V2.0”的基础上,通过增加任务要求,熟悉二维数组作函数数、字符串处理函数、字符串处理操作、模块化设计程序设计以及增量测试方法。 学生成绩管理系统V4.0 【教学要求】掌握二维数组作函数数,模块化程序设计以及增量测试方法。 【教学重点】 1.二维字符数组作函数数 2. 模块化程序设计以及增量测试方法 【教学难点】 1.二维字符数组作函数数 2. 模块化程序设计以及增量测试方法 【主要仪器设备及材料】 安装有C语言开发环境的电脑 【主要内容】 学生成绩管理系统V4.0 某班有最多超过30具体人数键盘输入加期末考试,考试科目最多超过6门(具体门数有键盘输入)。考例8.12,用二维数组作函数数编程实现如下菜单驱动的学生成绩管理系统: (1)录入每个学生的学号、姓名和考试成绩; (2)计算每门课程的总分和平均分; (3)计算每个学生的总分和平均分; (4)按每个学生的总分由高到低排出名次表; (5)按每个学生的总分由低到高排出名次表; (6)按学号由小到大排出成绩表; (7)按姓名的字典顺序排出成绩表; (8)按学号查询学生排名及其各科考试成绩; (9)按姓名查询学生排名及其各科考试成绩; (10)按优秀(90~100)、良好(80~89)、中等(70~79)、及格(60~69)、及格(0~59)5个类别,统计每个类别的人数以及所占的百分比; (11)输出每个学生的学号、姓名、各科考试成绩、总分和平均分,以及每门课程的总分和平均分。 要求程序运行后先显示如下菜单,并提示用户输入选项: 1.Input record 2.Caculate total and average score of every course 3. Caculate total and average score of every student 4.Sort in descending order by total score of every student 5.Sort in ascending order by total score of every student 6.Sort in ascending order by number 7.Sort in dictionary by name 8.Search by number 9.Search by name 10.Statistic analysis for every course 11.List record 0.Exit Please enter your choice: 然后,根据用户输入的选项执行相应的操作。 实验目的:在第10实验学生成绩管理系统V3.0”的基础上,通过增加任务要求,熟悉二维数组作函数数、模块化设计程序设计以及增量测试方法。 学生成绩管理系统V5.0 【教学要求】 掌握结构体类型,结构体数组作函数数,模块化设计程序设计以及增量测试方法。 【教学重点】 1.掌握结构体类型。 2.结构体数组作函数数 3.模块化设计程序设计以及增量测试方法 【教学难点】 1.结构体数组作函数数 2.模块化设计程序设计以及增量测试方法, 【主要仪器设备及材料】 安装有C语言开发环境的电脑 【主要内容】 学生成绩管理系统V5.0 某班有最多超过30具体人数键盘输入加期末考试,考试科目最多超过6门(具体门数有键盘输入)。考例12.7,定义结构体类型,用结构体数组作函数数,编程实现如下菜单驱动的学生成绩管理系统: (1)录入每个学生的学号、姓名和各科考试成绩; (2)计算每门课程的总分和平均分; (3)计算每个学生的总分和平均分; (4)按每个学生的总分由高到低排出名次表; (5)按每个学生的总分由低到高排出名次表; (6)按学号由小到大排出成绩表; (7)按姓名的字典顺序排出成绩表; (8)按学号查询学生排名及其考试成绩; (9)按姓名查询学生排名及其考试成绩; (10)按优秀(90~100)、良好(80~89)、中等(70~79)、及格(60~69)、及格(0~59)5个类别,统计每个类别的人数以及所占的百分比; (11)输出每个学生的学号、姓名、各科考试成绩、总分和平均分。 要求程序运行后先显示如下菜单,并提示用户输入选项: 1.Input record 2.Caculate total and average score of every course 3. Caculate total and average score of every student 4.Sort in descending order by total score of every student 5.Sort in ascending order by total score of every student 6.Sort in ascending order by number 7.Sort in dictionary order by name 8.Search by number 9.Search by name 10.Statistic analysis for every course 11.List record 0.Exit Please enter your choice: 然后,根据用户输入的选项执行相应的操作。 实验目的:在第11实验学生成绩管理系统V4.0”的基础上,通过增加任务要求,熟悉结构体类型,结构体数组作函数数,模块化设计程序设计以及增量测试方法,体会应用结构体类型代替普通的数组类型的优越性。 学生成绩管理系统V6.0 【教学要求】 熟悉文件的基本操作,模块化设计程序设计以及增量测试方法。 【教学重点】 1.文件的基本操作 2.模块化设计程序设计以及增量测试方法 【教学难点】 1.文件的基本操作 2.模块化设计程序设计以及增量测试方法 【主要仪器设备及材料】 安装有C语言开发环境的电脑 【主要内容】 学生成绩管理系统V6.0 某班有最多超过30具体人数键盘输入加期末考试,考试科目最多超过6门(具体门数由键盘输入)。学生成绩管理系统是一个非常实用的程序,如果能够把用户输入的数据存盘,下次运行时读出,就更有用了。考例13.7,增加文件读写的功能,即编程实现如下菜单驱动的学生成绩管理系统: (1)录入每个学生的学号、姓名和各科考试成绩; (2)计算每门课程的总分和平均分; (3)计算每个学生的总分和平均分; (4)按每个学生的总分由高到低排出名次表; (5)按每个学生的总分由低到高排出名次表; (6)按学号由小到大排出成绩表; (7)按姓名的字典顺序排出成绩表; (8)按学号查询学生排名及其考试成绩; (9)按姓名查询学生排名及其考试成绩; (10)按优秀(90~100)、良好(80~89)、中等(70~79)、及格(60~69)、及格(0~59)5个类别,对每门课程分别统计每个类别的人数以及所占的百分比; (11)输出每个学生的学号、姓名、各科考试成绩,以及每门课程的总分和平均分。 (12)将每个学生的记录信息写入文件; (13)从文件中读出每个学生的记录信息并显示。 要求程序运行后先显示如下菜单,并提示用户输入选项: 1.Input record 2.Caculate total and average score of every course 3.Caculate total and average score of every student 4.Sort in descending order by total score of every student 5.Sort in ascending order by total score of every student 6.Sort in ascending order by number 7.Sort in dictionary order by name 8.Search by number 9.Search by name 10.Statistic analysis for every course 11.List record 12.Write to a file 13.Read from a file 0.Exit Please enter your choice: 然后,根据用户输入的选项执行相应的操作。 实验目的:在第12实验学生成绩管理系统V5.0”的基础上,通过增加任务要求,熟悉文件的基本操作,模块化设计程序设计以及增量测试方法。
最新发布
06-17
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值