文章目录

  • 学生成绩管理系统V1.0
  • 学生成绩管理系统V2.0
  • 学生成绩管理系统V3.0
  • 学生成绩管理系统V4.0
  • 学生成绩管理系统V5.0

本文提供测试数据哦~
运行时请将数据粘贴到输入框中。

  • 由于自己才疏学浅,难免会有纰漏,假如你发现了有错误的地方,还望留言给我指出来,我会对其加以修正。
  • 如果你觉得文章还不错,你的转发、分享、赞赏、点赞、留言就是对我最大的鼓励。
  • 感谢您的阅读,十分欢迎并感谢您的关注哦~

学生成绩管理系统V1.0

/*注意: 本题没有空行! 所以一定要检查\n的使用!!!
数据:
11003001 87
11003005 98
11003003 75
11003002 48
11003004 65
11003006 100
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>void printMessage();
void input(double score[], long id[], int n);
void caculate(double score[], int n);
void sortScore(double score[], long id[], int n);  //成绩降序
void sortNum(double score[], long id[], int n);    //学号升序
void search(double score[], long id[], int n);
void statistic(double score[], long id[], int n);
void output(double score[], long id[], int n);
void endProgram();
void wrong();int main()
{int n = 0, choice = 0;long id[35];double score[35];printf("Input student number(n<30):\n");scanf("%d", &n);while(true){printMessage();scanf("%d", &choice);switch(choice){case 1: input(score, id, n);break;case 2: caculate(score, n);break;case 3: sortScore(score, id, n);break;case 4: sortNum(score, id, n); break;case 5: search(score, id, n); break;case 6: statistic(score, id, n); break;case 7: output(score, id, n);break;case 0: endProgram(); break;default: wrong(); break;}}return 0;}void printMessage()
{printf("Management for Students' scores\n");printf("1.Input record\n");printf("2.Caculate total and average score of course\n");printf("3.Sort in descending order by score\n");printf("4.Sort in ascending order by number\n");printf("5.Search by number\n");printf("6.Statistic analysis\n");printf("7.List record\n");printf("0.Exit\n");printf("Please Input your choice:\n");}void input(double score[], long id[], int n)   //1
{printf("Input student's ID, name and score:\n");for(int i = 0; i < n; i++){scanf("%ld%lf", &id[i], &score[i]);}}void caculate(double score[], int n)   //2
{double sum = 0;for(int i = 0; i < n; i++){sum += score[i];}printf("sum=%.0f,aver=%.2f\n", sum, sum / n);}void sortScore(double score[], long id[], int n)   //3: 成绩降序
{printf("Sort in descending order by score:\n");for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if(score[j] < score[j + 1]){double tempScore = score[j];score[j] = score[j + 1];score[j + 1] = tempScore;long tempId = id[j];id[j] = id[j + 1];id[j + 1] = tempId;}}}/*打印*/for(int i = 0; i < n; i++){printf("%ld\t%.0f\n", id[i], score[i]);}}void sortNum(double score[], long id[], int n)   //4: 学号升序
{printf("Sort in ascending order by number:\n");for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if(id[j] > id[j + 1]){double tempScore = score[j];score[j] = score[j + 1];score[j + 1] = tempScore;long tempId = id[j];id[j] = id[j + 1];id[j + 1] = tempId;}}}/*打印*/for(int i = 0; i < n; i++){printf("%ld\t%.0f\n", id[i], score[i]);}}void search(double score[], long id[], int n)   //5
{long searchNum = 0;printf("Input the number you want to search:\n");scanf("%ld", &searchNum);bool flag = false;for(int i = 0; i < n; i++){if(id[i] == searchNum){printf("%ld\t%.0f\n", id[i], score[i]);flag = true;}}if(flag == false){printf("Not found!\n");}}void statistic(double score[], long id[], int n)   //6: 可以再优化一下
{double statisticScore[6] = {0};for(int i = 0; i < n; i++){switch((int)score[i] / 10){case 0:case 1:case 2:case 3:case 4:case 5: statisticScore[0]++; break;case 6: statisticScore[1]++; break;case 7: statisticScore[2]++; break;case 8: statisticScore[3]++; break;case 9: statisticScore[4]++; break;case 10: statisticScore[5]++; break;default: wrong(); break;}}/* 输出部分 */printf("<60\t%d\t%.2f%%\n", (int)statisticScore[0], statisticScore[0] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 60, 69, (int)statisticScore[1], statisticScore[1] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 70, 79, (int)statisticScore[2], statisticScore[2] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 80, 89, (int)statisticScore[3], statisticScore[3] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 90, 99, (int)statisticScore[4], statisticScore[4] / n * 100);printf("%d\t%d\t%.2f%%\n", 100, (int)statisticScore[5], statisticScore[5] / n * 100);}void output(double score[], long id[], int n)   //7
{for(int i = 0; i < n; i++){printf("%ld\t%.0f\n", id[i], score[i]);}}void endProgram()   //0
{printf("End of program!\n");exit(0);}void wrong()   //default
{printf("Input error!\n");}

学生成绩管理系统V2.0

/*
数据:
11003001 87
11003005 98
11003003 75
11003002 48
11003004 65
11003006 100
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>void PrintMessage();
void Input(double score[], long id[], int n);
void Caculate(double score[], int n);void SortScore(double score[], long id[], int n, bool (*compare)(double, double));  //成绩通用排序
bool Ascending(double x, double y);
bool Descending(double x, double y);void SortNum(double score[], long id[], int n);    //学号升序
void Search(double score[], long id[], int n);
void Statistic(double score[], long id[], int n);
void Output(double score[], long id[], int n);
void EndProgram();
void Wrong();int main()
{int n = 0, choice = 0;long id[35];double score[35];printf("Input student number(n<30):\n");scanf("%d", &n);while(true){PrintMessage();scanf("%d", &choice);switch(choice){case 1:Input(score, id, n);break;case 2:Caculate(score, n);break;case 3:printf("Sort in descending order by score:\n");SortScore( score, id, n, Descending );break;case 4:printf("Sort in ascending order by score:\n");SortScore( score, id, n, Ascending );break;case 5:SortNum(score, id, n);break;case 6:Search(score, id, n);break;case 7:Statistic(score, id, n);break;case 8:Output(score, id, n);break;case 0:EndProgram();break;default:Wrong();break;}}return 0;}void PrintMessage()
{printf("Management for Students' scores\n");printf("1.Input record\n");printf("2.Caculate total and average score of course\n");printf("3.Sort in descending order by score\n");printf("4.Sort in ascending order by score\n");printf("5.Sort in ascending order by number\n");printf("6.Search by number\n");printf("7.Statistic analysis\n");printf("8.List record\n");printf("0.Exit\n");printf("Please Input your choice:\n");
}void Input(double score[], long id[], int n)   //1
{printf("Input student's ID and score:\n");   //V2.0更改!for(int i = 0; i < n; i++){scanf("%ld%lf", &id[i], &score[i]);}
}void Caculate(double score[], int n)   //2
{double sum = 0;for(int i = 0; i < n; i++){sum += score[i];}printf("sum=%.0f,aver=%.2f\n", sum, sum / n);
}void SortScore(double score[], long id[], int n, bool (*compare)(double, double))  //成绩通用排序
{for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if( (*compare)(score[j], score[j + 1]) ){double tempScore = score[j];score[j] = score[j + 1];score[j + 1] = tempScore;long tempId = id[j];id[j] = id[j + 1];id[j + 1] = tempId;}}}/*打印*/for(int i = 0; i < n; i++){printf("%ld\t%.0f\n", id[i], score[i]);}
}bool Ascending(double x, double y)   //4
{return x > y;
}bool Descending(double x, double y)   //3
{return x < y;
}void SortNum(double score[], long id[], int n)   //5: 学号升序
{printf("Sort in ascending order by number:\n");for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if(id[j] > id[j + 1]){double tempScore = score[j];score[j] = score[j + 1];score[j + 1] = tempScore;long tempId = id[j];id[j] = id[j + 1];id[j + 1] = tempId;}}}/*打印*/for(int i = 0; i < n; i++){printf("%ld\t%.0f\n", id[i], score[i]);}
}void Search(double score[], long id[], int n)   //6:查找
{long searchNum = 0;printf("Input the number you want to search:\n");scanf("%ld", &searchNum);bool flag = false;for(int i = 0; i < n; i++){if(id[i] == searchNum){printf("%ld\t%.0f\n", id[i], score[i]);flag = true;}}if(flag == false){printf("Not found!\n");}
}void Statistic(double score[], long id[], int n)   //7:统计, 可以再优化一下
{double statisticScore[6] = {0};for(int i = 0; i < n; i++){switch((int)score[i] / 10){case 0:case 1:case 2:case 3:case 4:case 5:statisticScore[0]++;break;case 6:statisticScore[1]++;break;case 7:statisticScore[2]++;break;case 8:statisticScore[3]++;break;case 9:statisticScore[4]++;break;case 10:statisticScore[5]++;break;default:Wrong();break;}}/*输出部分*/printf("<60\t%d\t%.2f%%\n", (int)statisticScore[0], statisticScore[0] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 60, 69, (int)statisticScore[1], statisticScore[1] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 70, 79, (int)statisticScore[2], statisticScore[2] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 80, 89, (int)statisticScore[3], statisticScore[3] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 90, 99, (int)statisticScore[4], statisticScore[4] / n * 100);printf("%d\t%d\t%.2f%%\n", 100, (int)statisticScore[5], statisticScore[5] / n * 100);
}void Output(double score[], long id[], int n)   //8
{for(int i = 0; i < n; i++){printf("%ld\t%.0f\n", id[i], score[i]);}
}void EndProgram()   //0
{printf("End of program!\n");exit(0);
}void Wrong()   //default
{printf("Input error!\n");
}

学生成绩管理系统V3.0

/*数据:
11003001
lisi
87
11003005
heli
98
11003003
ludi
75
11003002
dumo
48
11003004
zuma
65
11003006
suyu
100
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>void PrintMessage();
void Input(double score[], long id[], int n, char name[][10]);           //1
void Caculate(double score[], int n);                                    //2void SortScore(double score[], long id[], int n, bool (*compare)(double, double), char name[][10]); //3与4
bool Ascending(double x, double y);
bool Descending(double x, double y);void SortbyId(double score[], long id[], int n, char name[][10]);        //5: 学号升序
void SortbyName(double score[], long id[], int n, char name[][10]);      //6: 按名字的字典序升序void SearchbyScore(double score[], long id[], int n, char name[][10]);   //7: 查找分数
void SearchbyName(double score[], long id[], int n, char name[][10]);    //8: 查找名字void Statistic(double score[], long id[], int n);                        //9
void Output(double score[], long id[], int n, char name[][10]);          //10
void EndProgram();   //0
void Wrong();        //defaultint main()
{int n = 0, choice = 0;long id[35] = {0};double score[35] = {0};printf("Input student number(n<30):\n");scanf("%d", &n);char name[35][10];while(true){PrintMessage();scanf("%d", &choice);switch(choice){case 1:Input(score, id, n, name);break;case 2:Caculate(score, n);break;case 3:printf("Sort in descending order by score:\n");SortScore( score, id, n, Descending, name );break;case 4:printf("Sort in ascending order by score:\n");SortScore( score, id, n, Ascending, name );break;case 5:SortbyId(score, id, n, name);break;case 6:SortbyName(score, id, n, name);break;case 7:SearchbyScore(score, id, n, name);break;case 8:SearchbyName(score, id, n, name);break;case 9:Statistic(score, id, n);break;case 10:Output(score, id, n, name);break;case 0:EndProgram();break;default:Wrong();break;}}return 0;}void PrintMessage()
{printf("Management for Students' scores\n");printf("1.Input record\n");printf("2.Caculate total and average score of course\n");printf("3.Sort in descending order by score\n");printf("4.Sort in ascending order by score\n");printf("5.Sort in ascending order by number\n");printf("6.Sort in dictionary order by name\n");printf("7.Search by number\n");printf("8.Search by name\n");printf("9.Statistic analysis\n");printf("10.List record\n");printf("0.Exit\n");printf("Please Input your choice:\n");
}void Input(double score[], long id[], int n, char name[][10])   //1
{printf("Input student's ID, name and score:\n");for(int i = 0; i < n; i++){scanf("%ld%s%lf", &id[i], name[i], &score[i]);}
}void Caculate(double score[], int n)   //2
{double sum = 0;for(int i = 0; i < n; i++){sum += score[i];}printf("sum=%.0f,aver=%.2f\n", sum, sum / n);
}void SortScore(double score[], long id[], int n, bool (*compare)(double, double), char name[][10])
{//成绩通用排序 3与4for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if( (*compare)(score[j], score[j + 1]) ){double tempScore = score[j];score[j] = score[j + 1];score[j + 1] = tempScore;long tempId = id[j];id[j] = id[j + 1];id[j + 1] = tempId;char tempName[10];strcpy(tempName, name[j]);strcpy(name[j], name[j + 1]);strcpy(name[j + 1], tempName);}}}/*打印*/for(int i = 0; i < n; i++){printf("%ld\t%s\t%.0f\n", id[i], name[i], score[i]);}
}bool Ascending(double x, double y)   //4
{return x > y;
}bool Descending(double x, double y)   //3
{return x < y;
}void SortbyId(double score[], long id[], int n, char name[][10])   //5: 学号升序
{printf("Sort in ascending order by number:\n");for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if(id[j] > id[j + 1]){double tempScore = score[j];score[j] = score[j + 1];score[j + 1] = tempScore;long tempId = id[j];id[j] = id[j + 1];id[j + 1] = tempId;char tempName[10];strcpy(tempName, name[j]);strcpy(name[j], name[j + 1]);strcpy(name[j + 1], tempName);}}}/* 输出语句 */for(int i = 0; i < n; i++){printf("%ld\t%s\t%.0f\n", id[i], name[i], score[i]);}
}void SortbyName(double score[], long id[], int n, char name[][10])   //6: 按名字的字典序升序
{printf("Sort in dictionary order by name:\n");for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if(strcmp(name[j], name[j + 1]) > 0){double tempScore = score[j];score[j] = score[j + 1];score[j + 1] = tempScore;long tempId = id[j];id[j] = id[j + 1];id[j + 1] = tempId;char tempName[10];strcpy(tempName, name[j]);strcpy(name[j], name[j + 1]);strcpy(name[j + 1], tempName);}}}/* 输出语句 */for(int i = 0; i < n; i++){printf("%ld\t%s\t%.0f\n", id[i], name[i], score[i]);}
}void SearchbyScore(double score[], long id[], int n, char name[][10])   //7:查找
{long searchNum = 0;printf("Input the number you want to search:\n");scanf("%ld", &searchNum);bool flag = false;for(int i = 0; i < n; i++){if(id[i] == searchNum){printf("%ld\t%s\t%.0f\n", id[i], name[i], score[i]);flag = true;}}if(flag == false){printf("Not found!\n");}
}void SearchbyName(double score[], long id[], int n, char name[][10])   //8: 查找名字
{char searchName[10];printf("Input the name you want to search:\n");scanf(" %10s", searchName);   //注意: 这里要加上一个空格来吃掉回车!bool flag = false;for(int i = 0; i < n; i++){if(strcmp(name[i], searchName) == 0){printf("%ld\t%s\t%.0f\n", id[i], name[i], score[i]);flag = true;}}if(flag == false){printf("Not found!\n");}
}void Statistic(double score[], long id[], int n)   //9:统计, 可以再要优化一下
{double statisticScore[6] = {0};for(int i = 0; i < n; i++){switch((int)score[i] / 10){case 0:case 1:case 2:case 3:case 4:case 5:statisticScore[0]++;break;case 6:statisticScore[1]++;break;case 7:statisticScore[2]++;break;case 8:statisticScore[3]++;break;case 9:statisticScore[4]++;break;case 10:statisticScore[5]++;break;default:Wrong();break;}}/* 输出部分 */printf("<60\t%d\t%.2f%%\n", (int)statisticScore[0], statisticScore[0] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 60, 69, (int)statisticScore[1], statisticScore[1] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 70, 79, (int)statisticScore[2], statisticScore[2] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 80, 89, (int)statisticScore[3], statisticScore[3] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 90, 99, (int)statisticScore[4], statisticScore[4] / n * 100);printf("%d\t%d\t%.2f%%\n", 100, (int)statisticScore[5], statisticScore[5] / n * 100);
}void Output(double score[], long id[], int n, char name[][10])   //10
{for(int i = 0; i < n; i++){printf("%ld\t%s\t%.0f\n", id[i], name[i], score[i]);}
}void EndProgram()   //0
{printf("End of program!\n");exit(0);
}void Wrong()        //default
{printf("Input error!\n");
}

学生成绩管理系统V4.0

//注意: 本题没有空行! 所以一定要检查\n的使用!!!
/*数据1:
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
*/
/*数据2:
6
1
3
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
2
3
4
5
6
7
8
11003007
8
11003004
9
lili
9
lisi
10
11
12
0
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>void PrintMessage();
void Input(double score[][6], long id[], char name[][10], int n, int m);           //1
void CaculateCourse(double score[][6], int n, int m);                              //2
void CaculateStudent(double score[][6], double totalScore[], int n, int m);        //3void SortScore(double score[][6], double totalScore[], long id[],char name[][10], int n, int m, bool (*compare)(double, double));
bool Ascending(double x, double y);
bool Descending(double x, double y);void SortbyId(double score[][6], double totalScore[],long id[], char name[][10], int n, int m);      //5: 学号升序
void SortbyName(double score[][6], double totalScore[],long id[], char name[][10], int n, int m);    //6: 按名字的字典序升序void SearchbyScore(double score[][6], double totalScore[], long id[],char name[][10], int n, int m); //7: 查找分数
void SearchbyName(double score[][6], double totalScore[], long id[],char name[][10], int n, int m);  //8: 查找名字void Statistic(double score[][6], long id[], int n, int m);                         //9: 统计
void Output(double score[][6], double totalScore[], long id[], char name[][10], int n, int m);  //10
void EndProgram();   //0
void Wrong();        //defaultvoid SwapD(double *x, double *y);
void SwapL(long *x, long *y);
void SwapStr(char x[], char y[]);
void SwapScore(double score[][6], int j, int m);int main()
{int n = 0;   /*学生人数*/int m = 0;   /*课程数目*/int choice = 0;long id[35] = {0};               //学生人数最多是35double score[35][6] = {0};       //最多考试的科目数是6double totalScore[35] = {0};   /*学生总分*/printf("Input student number(n<30):\n");scanf("%d", &n);char name[35][10];   /*学生人数最多是35, 名字最长为10*/while(true){PrintMessage();scanf("%d", &choice);switch(choice){case 1:printf("Input course number(m<=%d):\n", 6);scanf("%d", &m);            //课程数目Input(score, id, name, n, m);break;case 2:CaculateCourse(score, n, m);break;case 3:CaculateStudent(score, totalScore, n, m);break;case 4:printf("Sort in descending order by score:\n");SortScore(score, totalScore, id, name, n, m, Descending);break;case 5:printf("Sort in ascending order by score:\n");SortScore(score, totalScore, id, name, n, m, Ascending);break;case 6:SortbyId(score, totalScore, id, name, n, m);break;case 7:SortbyName(score, totalScore, id, name, n, m);break;case 8:SearchbyScore(score, totalScore, id, name, n, m);break;case 9:SearchbyName(score, totalScore, id, name, n, m);break;case 10:Statistic(score, id, n, m);break;case 11:Output(score, totalScore, id, name, n, m);break;case 0:EndProgram();break;default:Wrong();break;}}return 0;}void PrintMessage()
{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");
}void Input(double score[][6], long id[], char name[][10], int n, int m)   //1
{printf("Input student's ID, name and score:\n");for(int i = 0; i < n; i++){scanf("%ld%s", &id[i], name[i]);for(int j = 0; j < m; j++){scanf("%lf", &score[i][j]);}}
}void CaculateCourse(double score[][6], int n, int m)   //2
{double sum = 0;for(int i = 0; i < m; i++)     //课程数{sum = 0;for(int j = 0; j < n; j++) //学生数{sum += score[j][i];}printf("course %d:sum=%.0f,aver=%.0f\n", i + 1, sum, sum / n);}
}void CaculateStudent(double score[][6], double totalScore[], int n, int m)   //3
{for(int i = 0; i < n; i++)     //学生数{for(int j = 0; j < m; j++) //课程数{totalScore[i] += score[i][j];}printf("student %d:sum=%.0f,aver=%.0f\n", i + 1, totalScore[i], totalScore[i] / m);}
}void SortScore(double score[][6], double totalScore[], long id[], char name[][10], int n, int m, bool (*compare)(double, double))
{//成绩通用排序 4与5for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if( (*compare)(totalScore[j], totalScore[j + 1]) ){SwapD(&totalScore[j], &totalScore[j + 1]);   /*注意这里的交换*/SwapL(&id[j], &id[j + 1]);SwapStr(name[j], name[j + 1]);SwapScore(score, j, m);}}}/*打印*/Output(score, totalScore, id, name, n, m);
}bool Descending(double x, double y)   //5
{return x < y;
}bool Ascending(double x, double y)   //4
{return x > y;
}void SortbyId(double score[][6], double totalScore[], long id[], char name[][10], int n, int m)   //6: 学号升序
{printf("Sort in ascending order by number:\n");for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if(id[j] > id[j + 1]){SwapD(&totalScore[j], &totalScore[j + 1]);   /*注意这里的交换*/SwapL(&id[j], &id[j + 1]);SwapStr(name[j], name[j + 1]);SwapScore(score, j, m);}}}/*打印*/Output(score, totalScore, id, name, n, m);
}void SortbyName(double score[][6], double totalScore[], long id[], char name[][10], int n, int m)   //7: 按名字的字典序升序
{printf("Sort in dictionary order by name:\n");for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if(strcmp(name[j], name[j + 1]) > 0){SwapD(&totalScore[j], &totalScore[j + 1]);   /*注意这里的交换*/SwapL(&id[j], &id[j + 1]);SwapStr(name[j], name[j + 1]);SwapScore(score, j, m);}}}/*打印*/Output(score, totalScore, id, name, n, m);
}void SearchbyScore(double score[][6], double totalScore[], long id[], char name[][10], int n, int m)   //8:查找
{long searchNum = 0;printf("Input the number you want to search:\n");scanf("%ld", &searchNum);bool flag = false;for(int i = 0; i < n; i++){if(id[i] == searchNum){flag = true;                           /*同下*/printf("%ld\t%s\t", id[i], name[i]);for(int j = 0; j < m; j++){printf("%.0f\t", score[i][j]);}printf("%.0f\t%.0f\n", totalScore[i], totalScore[i] / m);break;                 //确保只输出一行}}if(flag == false){printf("Not found!\n");}
}void SearchbyName(double score[][6], double totalScore[], long id[], char name[][10], int n, int m)   //8: 查找名字
{char searchName[10];printf("Input the name you want to search:\n");scanf(" %10s", searchName);   //注意: 这里要加上一个空格来吃掉回车!bool flag = false;for(int i = 0; i < n; i++){if(strcmp(name[i], searchName) == 0){flag = true;                         /*同上*/printf("%ld\t%s\t", id[i], name[i]);for(int j = 0; j < m; j++){printf("%.0f\t", score[i][j]);}printf("%.0f\t%.0f\n", totalScore[i], totalScore[i] / m);break;               //确保只输出一行}}if(flag == false){printf("Not found!\n");}
}void Statistic(double score[][6], long id[], int n, int m)   //10:统计
{for(int j = 0; j < m; j++)          /*主循环次数: 课程数m*/{double statisticScore[6] = {0};for(int i = 0; i < n; i++){switch((int)score[i][j] / 10){case 0:case 1:case 2:case 3:case 4:case 5:statisticScore[0]++;break;case 6:statisticScore[1]++;break;case 7:statisticScore[2]++;break;case 8:statisticScore[3]++;break;case 9:statisticScore[4]++;break;case 10:statisticScore[5]++;break;default:Wrong();break;}}/* 输出部分 */printf("For course %d:\n", j + 1);printf("<60\t%d\t%.2f%%\n", (int)statisticScore[0], statisticScore[0] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 60, 69, (int)statisticScore[1], statisticScore[1] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 70, 79, (int)statisticScore[2], statisticScore[2] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 80, 89, (int)statisticScore[3], statisticScore[3] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 90, 99, (int)statisticScore[4], statisticScore[4] / n * 100);printf("%d\t%d\t%.2f%%\n", 100, (int)statisticScore[5], statisticScore[5] / n * 100);}
}void Output(double score[][6], double totalScore[], long id[], char name[][10], int n, int m)   //11
{for(int i = 0; i < n; i++){printf("%ld\t%s\t", id[i], name[i]);for(int j = 0; j < m; j++){printf("%.0f\t", score[i][j]);}printf("%.0f\t%.0f\n", totalScore[i], totalScore[i] / m);}                                             //注意这里是课程数m
}void EndProgram()   //0
{printf("End of program!\n");exit(0);
}void Wrong()        //default
{printf("Input error!\n");
}void SwapD(double *x, double *y)  /*注意交换两个数*/
{double temp = *x;*x = *y;*y = temp;
}void SwapL(long *x, long *y)     /*注意交换两个数*/
{long temp = *x;*x = *y;*y = temp;
}void SwapStr(char x[], char y[])
{char temp[10];strcpy(temp, x);strcpy(x, y);strcpy(y, temp);
}void SwapScore(double score[][6], int j, int m)
{for(int k = 0; k < m; k++)   /*将二位数组整行交换*/{double temp = score[j][k];score[j][k] = score[j + 1][k];score[j + 1][k] = temp;}
}

学生成绩管理系统V5.0

/*数据:
6
1
3
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
2
3
4
5
6
7
8
11003007
8
11003004
9
lili
9
lisi
10
11
12
0
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define  MAX_LEN  10               /* 名字最大长度 */
#define  STU_NUM 30                /* 最多的学生人数 */
#define  COURSE_NUM 6              /* 最多的考试科目数 */typedef struct student
{long num;                  /* 学号 */char name[MAX_LEN];         /* 姓名 */double score[COURSE_NUM];   /* 每个学生各门功课的成绩 */double sum;                 /* 总成绩 */double 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)(double a, double b));
int   Ascending(double a, double b);
int   Descending(double a, double b);
void  SwapSTU(STU *a, STU *b);
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");    //是<= 程序示例中有错误scanf("%d", &n);while(true){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)
{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");int choice = 0;scanf("%d", &choice);return choice;
}/* 函数功能:输入n个学生的m门课成绩 */
void ReadScore(STU stu[], int n, int m)
{printf("Input student's ID, name and score:\n");for(int i = 0; i < n; i++){scanf("%ld%s", &stu[i].num, stu[i].name);for(int j = 0; j < m; j++){scanf("%lf", &stu[i].score[j]);}}
}/* 函数功能:计算每门课程的总分和平均分 */
void AverSumofEveryCourse(STU stu[], int n, int m)
{double sum = 0;for(int i = 0; i < m; i++)     //课程数{sum = 0;for(int j = 0; j < n; j++) //学生数{sum += stu[j].score[i];}printf("course %d:sum=%.0f,aver=%.0f\n", i + 1, sum, sum / n);}
}/* 函数功能:计算每个学生总分和平均分 */
void AverSumofEveryStudent(STU stu[], int n, int m)
{for(int i = 0; i < n; i++){stu[i].sum = 0;             //易错点: 一定要为结构体先赋初值~~~for(int j = 0; j < m; j++){stu[i].sum += stu[i].score[j];}stu[i].aver = stu[i].sum / m;}for(int i = 0; i < n; i++){printf("student %d: sum=%.0f,aver=%.0f\n", i + 1, stu[i].sum, stu[i].aver);}                 //空格~
}/* 函数功能:按冒泡法将学生的总分sum进行排序 */
void SortbyScore(STU stu[], int n, int m, int (*compare)(double a, double b))
{for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if( (*compare)(stu[j].sum, stu[j + 1].sum) ){SwapSTU(&stu[j], &stu[j + 1]);}}}
}/* 使数据按升序排序 */
int Ascending(double a, double b)
{return a > b;
}/* 使数据按降序排序 */
int Descending(double a, double b)
{return a < b;
}/* 交换两个结构体 */
void SwapSTU(STU *a, STU *b)
{STU temp = *a;*a = *b;*b = temp;
}/* 函数功能:按冒泡法将数组num的元素值按从低到高排序 */
void AsSortbyNum(STU stu[], int n, int m)
{for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if(stu[j].num > stu[j + 1].num){SwapSTU(&stu[j], &stu[j + 1]);}}}
}/* 函数功能:冒泡法实现名字按字典顺序升序排序 */
void SortbyName(STU stu[], int n, int m)
{for(int i = 0; i < n - 1; i++){for(int j = 0; j < n - 1 - i; j++){if(strcmp(stu[j].name, stu[j + 1].name) > 0){SwapSTU(&stu[j], &stu[j + 1]);}}}
}/* 函数功能:按学号查找学生成绩并显示查找结果 */
void SearchbyNum(STU stu[], int n, int m)
{long searchNum = 0;printf("Input the number you want to search:\n");scanf("%ld", &searchNum);bool flag = false;for(int i = 0; i < n; i++){if(stu[i].num == searchNum){flag = true;                           /*同下*/printf("%ld\t%s\t", stu[i].num, stu[i].name);for(int j = 0; j < m; j++){printf("%.0f\t", stu[i].score[j]);}printf("%.0f\t%.0f\n", stu[i].sum, stu[i].aver);break;                 //确保只输出一行}}if(flag == false){printf("Not found!\n");}
}/* 函数功能:按姓名的字典顺序排出成绩表 */
void SearchbyName(STU stu[], int n, int m)
{char searchName[10];printf("Input the name you want to search:\n");scanf(" %10s", searchName);   //注意: 这里要加上一个空格来吃掉回车!bool flag = false;for(int i = 0; i < n; i++){if(strcmp(stu[i].name, searchName) == 0){flag = true;                         /*同上*/printf("%ld\t%s\t", stu[i].num, stu[i].name);for(int j = 0; j < m; j++){printf("%.0f\t", stu[i].score[j]);}printf("%.0f\t%.0f\n", stu[i].sum, stu[i].aver);break;               //确保只输出一行}}if(flag == false){printf("Not found!\n");}
}/* 函数功能:统计各分数段的学生人数及所占的百分比 */
void StatisticAnalysis(STU stu[], int n, int m)
{for(int j = 0; j < m; j++)          /* 主循环次数: 课程数m */{double statisticScore[6] = {0};for(int i = 0; i < n; i++){switch((int)stu[i].score[j] / 10){case 0:case 1:case 2:case 3:case 4:case 5:statisticScore[0]++;break;case 6:statisticScore[1]++;break;case 7:statisticScore[2]++;break;case 8:statisticScore[3]++;break;case 9:statisticScore[4]++;break;case 10:statisticScore[5]++;break;default:printf("Not found!\n");break;}}/*输出部分*/printf("For course %d:\n", j + 1);printf("<60\t%d\t%.2f%%\n", (int)statisticScore[0], statisticScore[0] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 60, 69, (int)statisticScore[1], statisticScore[1] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 70, 79, (int)statisticScore[2], statisticScore[2] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 80, 89, (int)statisticScore[3], statisticScore[3] / n * 100);printf("%d-%d\t%d\t%.2f%%\n", 90, 99, (int)statisticScore[4], statisticScore[4] / n * 100);printf("%d\t%d\t%.2f%%\n", 100, (int)statisticScore[5], statisticScore[5] / n * 100);}
}/* 函数功能: 打印学生成绩 */
void PrintScore(STU stu[], int n, int m)
{for(int i = 0; i < n; i++){printf("%ld\t%s\t", stu[i].num, stu[i].name);for(int 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~5.0相关推荐

  1. 哈工大慕课 学生成绩管理系统V3.0

    题目内容: 某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,用二维字符数组作函数参数编程实现如下菜单驱动的学生成绩管理系统: (1)录入每个学生的学号.姓名和考试成绩: (2)计算课程 ...

  2. 第8章实验1:学生成绩管理系统V1.0

    第8章实验1:学生成绩管理系统V1.0 某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,用一维数组作函数参数编程实现如下学生成绩管理: (1)录入每个学生的学号和考试成绩: (2)计算 ...

  3. 学生成绩管理系统V1.0

    题目描述 某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,用一维数组作函数参数编程实现如下学生成绩管理: (1)录入每个学生的学号和考试成绩: (2)计算课程的总分和平均分: (3)按 ...

  4. VB实训项目:学生成绩管理系统V1.0

    文章目录 一.项目概述 二.运行效果演示 1.启动界面 2.用户登录 3.系统主界面

  5. ♥数据库课程设计之《学生成绩管理系统》♥

    0.写在前面 展示的是很常规的<学生成绩管理系统>,但是可修改为任何管理系统,只需要改些字段即可,具备java基础即可 简单的增删改查均可实现,本来很简单的几页文档就能交了,老师非得让详细 ...

  6. 用Java创建一个学生成绩管理系统登陆界面(初级)

    目录 任务与要求 代码部分 部分代码: 完整代码: 任务与要求 使用eclipse.exe创建一个登录界面,如图1所示,当用户名输入"lili",密码输入"123456& ...

  7. C语言项目—学生成绩管理系统(完结)

    C语言项目 1.学生成绩管理系统 本项目旨在增强,学习C语言的指针和链表部分知识 1.1 功能需求部分介绍 此处首先介绍一下该项目要完成的功能主要包括如下9个功能: 1.录入学生信息:即链表的功能 2 ...

  8. 基于python的学生成绩管理系统

    1. 运行效果 功能 录入学生信息 查找学生信息 删除学生信息 修改学生信息 排序 统计学生信息 显示所有学生信息 基于python的学生成绩管理系统,具备基本的增删改查功能,包含:录入学生信息.查找 ...

  9. java简单学生成绩系统_JAVA 实现简单的学生成绩管理系统

    一.实验目的 1.掌握java的类与对象的基本概念: 2.掌握简单的信息管理系统的设计与实现. 二.实验环境 实验建议在安装了以下软件的计算机上完成: 1.       Windows xp/win7 ...

最新文章

  1. 当使用视觉SLAM对一个环境建图之后,如何让机器人能够“理解”地图并导航呢? - 知乎
  2. 探讨微软团队开发利器VSTS之安装及部署篇
  3. UA SIE545 优化理论基础4 对偶理论简介2 弱对偶与Duality Gap
  4. python操作Excel的5种方式
  5. linux mv 环境变量,linux环境变量 cp mv 以及文档查看的几个命令
  6. Python MySQLdb 循环插入execute与批量插入executemany性能分析(list批量写法亲测成功)
  7. 2021阿里巴巴大数据技术公开课第一季:外部工具连接SaaS模式云数仓MaxCompute实战
  8. hadoop启动碰到java.net.UnknownHostException
  9. 利用FSMT进行文件服务器迁移及整合
  10. C语言实现Winsocket网络传输数据时乱码问题
  11. “BASH: FORK: RESOURCE TEMPORARILY UNAVAILABLE”的解决方案
  12. 使用翻译器扫描图片后,里面的日文可以被翻译出来吗?
  13. UE4设置人物移动和人物视角
  14. 精密划片机维护及保养
  15. redirect_uri 域名与后配置不一致是什么意思_中科三方DNS专家手把手教学——定位域名解析不生效问题...
  16. mac系统用键盘操作菜单栏
  17. 学python要多少钱-python编程培训需要多少钱?
  18. 《关于费尔巴哈的提纲》 马克思主义哲学中人的本质
  19. 【总结】1183- 毕业去字节之前的一些感想
  20. 066-PHP通过函数名调用函数

热门文章

  1. CAT1模块EC200S 4G物联网模块串口透传MQTT协议 快速入门指导资料
  2. oracle ora_p0,ORA-12801: error signaled in parallel query server P005
  3. cad角度怎么画_软件CAD | 直线amp;构造线
  4. 服务器开机显示f1 f2,开机提示按F1/F2才能进入系统的解决方法
  5. python之客户流失预警
  6. 如何用AI快速绘制大鼠模型及相关技术路线图,超详细教程!
  7. 元音I、i 、ε、æ、a小总结
  8. 织梦系统基本参数php,织梦后台系统基本参数新增的变量数据库修改
  9. 实现财务自由的关键词汇
  10. 瘦,是一种信仰。轻,是一种理想