• 【升级版学生信息管理系统&员工工资信息管理系统】+文件操作+更多细节


    目录

    1.功能介绍(主菜单-有什么功能)

     2.结构体的定义(定义一个结构体类型)

    3.主函数(如何调用分函数)

    4.初始化顺序表(数组加上数组的附加信息)

    5.退出程序同时保存数据到文档

    6.增加员工信息

    7.删除员工信息

     8.按照名字查找(查询工资信息)

    9. 修改员工信息

    10. 按照工资排序

    11.按照工号排序

    12. 计算工资信息

     13.打印工资信息

    14. 统计员工总数

    15.default语句

     16.源代码


    1.功能介绍(主菜单-有什么功能)

    讲一下:这个0123的标号的伏笔

    1. //菜单函数
    2. void Meau(void)
    3. {
    4. printf("--------------------------------\n");
    5. printf("--- 欢迎来到员工工资管理系统 ---\n");
    6. printf("--------------------------------\n");
    7. printf("---- 0.退出程序 ----\n");
    8. printf("---- 1.增加工资信息 ----\n");
    9. printf("---- 2.删除工资信息 ----\n");
    10. printf("---- 3.按名字查工资 ----\n");
    11. printf("---- 4.修改工资信息 ----\n");
    12. printf("---- 5.按照工资排序 ----\n");
    13. printf("---- 6.按照工号排序 ----\n");
    14. printf("---- 7.计算员工工资 ----\n");
    15. printf("---- 8.打印工资信息 ----\n");
    16. printf("---- 9.统计员工人数 ----\n");
    17. printf("-------------------------------\n");
    18. }

     2.结构体的定义(定义一个结构体类型)

    1.画一个盒子的嵌套图

    2.各种结构体类型成员的命名和函数命名规范

    3.typedef类型重命名

    4.size和capacity 的引入

    5.计算员工工资放的位置

    1. typedef struct Employee
    2. {
    3. char name[20];
    4. char id[20];
    5. double InitWages;
    6. double bonus;
    7. double deduct;
    8. double NextWages;
    9. double taxes;
    10. double FinaWages;
    11. }Employee;
    12. typedef struct SeqList
    13. {
    14. Employee* emp;
    15. int size;
    16. int capacity;
    17. }SeqList;

    3.主函数(如何调用分函数)

    1.do while语句(前后呼应)

    2.switch case  break;语句和case内部的每一步在干干嘛

    3.传值调用和传址调用

    1. int main()
    2. {
    3. int input = 0;
    4. SeqList ST;
    5. InitSeqList(&ST);
    6. do//先执行一次
    7. {
    8. Meau();
    9. printf("请输入您的选择(提示:请在0-9之间选择):>");
    10. scanf("%d", &input);
    11. switch (input)
    12. {
    13. case 0:
    14. printf("欢迎您的使用,即将退出程序.\n");
    15. SaveSeqList(&ST);
    16. break;
    17. case 1:
    18. printf("********增加工资信息.********\n");
    19. int nums = 0;
    20. printf("请输入您要增加的员工信息的员工数量:>");
    21. scanf("%d", &nums);
    22. Employee temp = { 0 };
    23. for (int i = 1; i <= nums; i++)
    24. {
    25. InitEmployee(&temp,i);
    26. AddSeqList(&ST,temp);
    27. }
    28. CountSeqList(&ST);
    29. break;
    30. case 2:
    31. printf("********删除工资信息.********\n");
    32. DelSeqList(&ST);
    33. break;
    34. case 3:
    35. printf("********查询工资信息.********\n");
    36. SearByName(&ST);
    37. break;
    38. case 4:
    39. printf("********修改工资信息.********\n");
    40. ModifySeqList(&ST);
    41. CountSeqList(&ST);
    42. break;
    43. case 5:
    44. printf("********按照工资排序.(从高到低)********\n");
    45. QsortByFinaWages(&ST,0,ST.size);
    46. PrintSeqList(&ST);
    47. break;
    48. case 6:
    49. printf("********按照工号排序.(从小到大)********\n");
    50. ShellSortById(&ST);
    51. PrintSeqList(&ST);
    52. break;
    53. case 7:
    54. printf("********计算员工工资********\n");
    55. CountSeqList(&ST);
    56. printf("计算成功.\n");
    57. break;
    58. case 8:
    59. printf("********打印工资信息********\n");
    60. PrintSeqList(&ST);
    61. break;
    62. case 9:
    63. printf("********统计员工人数********\n");
    64. printf("当前系统人数:%d\n", ST.size);
    65. default:
    66. printf("********输入错误,请重新输入********\n");
    67. break;
    68. }
    69. } while (input);
    70. }

    以下是功能的具体实现

    4.初始化顺序表(数组加上数组的附加信息)

    1.size和capacity的关系-->扩容(检查是否满了)

    2.初始化

    3.把上一次的数据加载到文件中-->持久化

    主:

    1. SeqList ST;
    2. InitSeqList(&ST);

    分:

    1. void CheckCapacity(SeqList* ps)
    2. {
    3. if (ps->size == ps->capacity)
    4. {
    5. int newcapacity = 2 * ps->capacity;
    6. Employee* temp = (Employee*)realloc(ps->emp,sizeof(Employee) * newcapacity);
    7. if (temp==NULL)
    8. {
    9. perror("CheckCapacity::realloc");
    10. return;
    11. }
    12. ps->emp = temp;
    13. ps->capacity = newcapacity;
    14. printf("扩容成功\n");
    15. }
    16. }
    17. void LoadSeqList(SeqList* ps)
    18. {
    19. FILE* pf = fopen("D:\\桌面\\test.txt", "rb");
    20. if (pf == NULL)
    21. {
    22. perror("LoadSeqList::fopen");
    23. return;
    24. }
    25. Employee temp = { 0 };
    26. while (fread(&temp, sizeof(Employee), 1, pf))
    27. {
    28. CheckCapacity(ps);
    29. ps->emp[ps->size] = temp;
    30. ps->size++;
    31. }
    32. fclose(pf);
    33. pf = NULL;
    34. }
    35. void InitSeqList(SeqList* ps)
    36. {
    37. ps->emp = (Employee*)malloc(sizeof(Employee) * 4);
    38. if (ps->emp == NULL)
    39. {
    40. perror("InitSeqList::malloc");
    41. return;
    42. }
    43. ps->size = 0;
    44. ps->capacity = 4;
    45. LoadSeqList(ps);
    46. }

    5.退出程序同时保存数据到文档

    1.文件的分类,为什么要有文件操作

    2.关于fopen函数,fread函数,fwrite函数

    主函数调用

    1. case 0:
    2. printf("欢迎您的使用,即将退出程序.\n");
    3. SaveSeqList(&ST);
    4. break;

    分函数实现

    1. void SaveSeqList(SeqList* ps)
    2. {
    3. FILE* pf = fopen("D:\\桌面\\test.txt", "wb");
    4. if (pf == NULL)
    5. {
    6. perror("LoadSeqList::fopen");
    7. return;
    8. }
    9. for (int i = 0; i < ps->size; i++)
    10. {
    11. fwrite(ps->emp + i, sizeof(Employee), 1, pf);
    12. }
    13. fclose(pf);
    14. pf = NULL;
    15. }

    6.增加员工信息

    1.打包操作

    2.顺序表的插入

    主:

    1. case 1:
    2. printf("********增加工资信息.********\n");
    3. int nums = 0;
    4. printf("请输入您要增加的员工信息的员工数量:>");
    5. scanf("%d", &nums);
    6. Employee temp = { 0 };
    7. for (int i = 1; i <= nums; i++)
    8. {
    9. InitEmployee(&temp,i);
    10. AddSeqList(&ST,temp);
    11. }
    12. CountSeqList(&ST);
    13. break;

    分:

    1. void InitEmployee(Employee* ps, int i)
    2. {
    3. printf("请输入第%d位待插入的员工工资信息:\n",i);
    4. printf("请输入员工姓名:>");
    5. scanf("%s", ps->name);
    6. printf("请输入员工工号:>");
    7. scanf("%s", ps->id);
    8. printf("请输入员工的基本工资:>");
    9. scanf("%lf", &(ps->InitWages));
    10. printf("请输入员工的奖金:>");
    11. scanf("%lf", &(ps->bonus));
    12. printf("请输入员工的扣款:>");
    13. scanf("%lf", &(ps->deduct));
    14. printf("请输入员工的税款:>");
    15. scanf("%lf", &(ps->taxes));
    16. }
    17. void AddSeqList(SeqList* ps, Employee temp)
    18. {
    19. CheckCapacity(ps);
    20. ps->emp[ps->size] = temp;
    21. ps->size++;
    22. printf("增加成功.\n");
    23. }

    7.删除员工信息

    0.局部变量和全局变量

    1.输入姓名,定位下标(封装成函数),strcmp函数,不存在返回-1 的原因

    2.存在则执行顺序表的删除操作,覆盖问题

    主:

    1. case 2:
    2. printf("********删除工资信息.********\n");
    3. DelSeqList(&ST);
    4. break;

    分:

    1. int FindByName(SeqList* ps,char* name)
    2. {
    3. for (int i = 0; i < ps->size; i++)
    4. {
    5. if (strcmp(name, ps->emp[i].name) == 0)
    6. {
    7. return i;
    8. }
    9. }
    10. return -1;
    11. }
    12. void DelSeqList(SeqList* ps)
    13. {
    14. if (ps->size == 0)
    15. {
    16. printf("当前员工总数为0,无法删除.\n");
    17. }
    18. char name[20] = { 0 };
    19. printf("请输入您要删除的员工信息的员工姓名:>");
    20. scanf("%s", name);
    21. int pos = FindByName(ps,name);
    22. if (pos == -1)
    23. {
    24. printf("当前系统中不存在名字为%s的员工.\n", name);
    25. return;
    26. }
    27. else
    28. {
    29. int begin = pos + 1;
    30. while (begin < ps->size)
    31. {
    32. ps->emp[begin -1] = ps->emp[begin];
    33. begin++;
    34. }
    35. ps->size--;
    36. }
    37. printf("删除成功.\n");
    38. }

     8.按照名字查找(查询工资信息)

    1.同上的定位函数

    2.打印下标为i的员工信息

    主:

    1. case 3:
    2. printf("********查询工资信息.********\n");
    3. SearByName(&ST);
    4. break;

    分:

    1. void SearByName(SeqList* ps)
    2. {
    3. char name[20] = { 0 };
    4. printf("请输入您要查询的员工信息的员工姓名:>");
    5. scanf("%s", name);
    6. int pos = FindByName(ps, name);
    7. if (pos == -1)
    8. {
    9. printf("当前系统中不存在名字为%s的员工.\n", name);
    10. return;
    11. }
    12. else
    13. {
    14. printf("%-20s %-20s %-10s %-10s %-10s %-10s %-10s %-10s\n", "员工姓名", "员工工号", "基本工资", "奖金", "扣款", "应发工资", "税款", "实发工资");
    15. printf("%-20s %-20s %-10.2lf %-10.2lf %-10.2lf %-10.2lf %-10.2lf %-10.2lf\n", \
    16. ps->emp[pos].name, ps->emp[pos].id, ps->emp[pos].InitWages, ps->emp[pos].bonus, ps->emp[pos].deduct, ps->emp[pos].NextWages, ps->emp[pos].taxes, ps->emp[pos].FinaWages);
    17. }
    18. }

    9. 修改员工信息

    1.同上

    2.修改if else if和go to 语句

    主:

    1. case 4:
    2. printf("********修改工资信息.********\n");
    3. ModifySeqList(&ST);
    4. CountSeqList(&ST);
    5. break;

    分: 

    1. void ModifySeqList(SeqList* ps)
    2. {
    3. char name[20] = { 0 };
    4. printf("请输入您要修改的员工信息的员工姓名:>");
    5. scanf("%s", name);
    6. int pos = FindByName(ps, name);
    7. if (pos == -1)
    8. {
    9. printf("当前系统中不存在名字为%s的员工.\n", name);
    10. return;
    11. }
    12. char choice[20] = { 0 };
    13. rechoice:
    14. printf("请输入你要修改的信息项目名称");
    15. printf("(提示:您可选择输入员工工号,基本工资,奖金,扣款,税款):>");
    16. scanf("%s", choice);
    17. printf("请输入修改后的该信息项目值:>");
    18. if (strcmp(choice, "员工工号") == 0)
    19. {
    20. scanf("%s", ps->emp[pos].id);
    21. }
    22. else if (strcmp(choice, "基本工资") == 0)
    23. {
    24. scanf("%lf", &(ps->emp[pos].InitWages));
    25. }
    26. else if (strcmp(choice, "奖金") == 0)
    27. {
    28. scanf("%lf", &(ps->emp[pos].bonus));
    29. }
    30. else if (strcmp(choice, "扣款") == 0)
    31. {
    32. scanf("%lf", &(ps->emp[pos].deduct));
    33. }
    34. else if (strcmp(choice, "税款") == 0)
    35. {
    36. scanf("%lf", &(ps->emp[pos].taxes));
    37. }
    38. else
    39. {
    40. printf("请在提示中给出的选项中做出选择!\n");
    41. goto rechoice;
    42. }
    43. printf("修改成功.\n");
    44. }

    10. 按照工资排序

    1.快速排序的原理

    主:

    1. case 5:
    2. printf("********按照工资排序.(从高到低)********\n");
    3. QsortByFinaWages(&ST,0,ST.size);
    4. PrintSeqList(&ST);
    5. break;

    分:

    1. void QsortByFinaWages(SeqList* ps, int begin, int end)
    2. {
    3. if (begin >= end)
    4. {
    5. return;
    6. }
    7. int keyi = begin;
    8. int left = begin, right = end;
    9. while (left < right)
    10. {
    11. while (left < right && ps->emp[right].FinaWages <= ps->emp[keyi].FinaWages)
    12. {
    13. right--;
    14. }
    15. while (left < right && ps->emp[left].FinaWages >= ps->emp[keyi].FinaWages)
    16. {
    17. left++;
    18. }
    19. Swap(&(ps->emp[left]), &(ps->emp[right]));
    20. }
    21. int meeti = left;
    22. Swap(&(ps->emp[keyi]), &(ps->emp[meeti]));
    23. QsortByFinaWages(ps, begin, meeti - 1);
    24. QsortByFinaWages(ps, meeti+1, end);
    25. }

    11.按照工号排序

    1.直接插入排序

    2.希尔排序的原理

    主:

    1. case 6:
    2. printf("********按照工号排序.(从小到大)********\n");
    3. ShellSortById(&ST);
    4. PrintSeqList(&ST);
    5. break;

    分:

    1. void ShellSortById(SeqList* ps)
    2. {
    3. int gap = ps->size;
    4. while (gap > 1)
    5. {
    6. gap = (gap / 3 + 1);
    7. for (int i = 0; i < ps->size - gap; i++)
    8. {
    9. int end = i;
    10. Employee temp = ps->emp[i + gap];
    11. while (end >= 0)
    12. {
    13. if (strcmp(ps->emp[end].id , temp.id)>0)
    14. {
    15. ps->emp[end + gap] = ps->emp[end];
    16. end -= gap;
    17. }
    18. else
    19. {
    20. break;
    21. }
    22. }
    23. ps->emp[end + gap] = temp;
    24. }
    25. }
    26. }

    12. 计算工资信息

    数学计算

    主:

    1. case 7:
    2. printf("********计算员工工资********\n");
    3. CountSeqList(&ST);
    4. printf("计算成功.\n");

    分:

    1. void CountSeqList(SeqList* ps)
    2. {
    3. for (int i = 0; i < ps->size; i++)
    4. {
    5. ps->emp[i].NextWages = ps->emp[i].InitWages + ps->emp[i].bonus - ps->emp[i].deduct;
    6. ps->emp[i].FinaWages = ps->emp[i].NextWages - ps->emp[i].taxes;
    7. }
    8. }

     13.打印工资信息

    格式控制

    主:

    1. case 8:
    2. printf("********打印工资信息********\n");
    3. PrintSeqList(&ST);
    4. break;

    分:

    1. void PrintSeqList(SeqList* ps)
    2. {
    3. printf("%-20s %-20s %-10s %-10s %-10s %-10s %-10s %-10s\n", "员工姓名", "员工工号", "基本工资", "奖金", "扣款", "应发工资","税款","实发工资");
    4. for (int i = 0; i < ps->size; i++)
    5. {
    6. printf("%-20s %-20s %-10.2lf %-10.2lf %-10.2lf %-10.2lf %-10.2lf %-10.2lf\n",\
    7. ps->emp[i].name,ps->emp[i].id, ps->emp[i].InitWages, ps->emp[i].bonus, ps->emp[i].deduct,ps->emp[i].NextWages,ps->emp[i].taxes,ps->emp[i].FinaWages);
    8. }
    9. }

    14. 统计员工总数

    1. case 9:
    2. printf("********统计员工人数********\n");
    3. printf("当前系统人数:%d\n", ST.size);

    15.default语句

    1. default:
    2. printf("********输入错误,请重新输入********\n");
    3. break;

     16.源代码

    1. //Employee.c
    2. #define _CRT_SECURE_NO_WARNINGS 1
    3. #define _CRT_SECURE_NO_WARNINGS 1
    4. #include<stdio.h>
    5. #include<stdlib.h>
    6. #include<string.h>
    7. #include<windows.h>
    8. typedef struct Employee
    9. {
    10. char name[20];
    11. char id[20];
    12. double InitWages;
    13. double bonus;
    14. double deduct;
    15. double NextWages;
    16. double taxes;
    17. double FinaWages;
    18. }Employee;
    19. typedef struct SeqList
    20. {
    21. Employee* emp;
    22. int size;
    23. int capacity;
    24. }SeqList;
    25. void CheckCapacity(SeqList* ps)
    26. {
    27. if (ps->size == ps->capacity)
    28. {
    29. int newcapacity = 2 * ps->capacity;
    30. Employee* temp = (Employee*)realloc(ps->emp,sizeof(Employee) * newcapacity);
    31. if (temp==NULL)
    32. {
    33. perror("CheckCapacity::realloc");
    34. return;
    35. }
    36. ps->emp = temp;
    37. ps->capacity = newcapacity;
    38. printf("扩容成功\n");
    39. }
    40. }
    41. void LoadSeqList(SeqList* ps)
    42. {
    43. FILE* pf = fopen("D:\\桌面\\test.txt", "rb");
    44. if (pf == NULL)
    45. {
    46. perror("LoadSeqList::fopen");
    47. return;
    48. }
    49. Employee temp = { 0 };
    50. while (fread(&temp, sizeof(Employee), 1, pf))
    51. {
    52. CheckCapacity(ps);
    53. ps->emp[ps->size] = temp;
    54. ps->size++;
    55. }
    56. fclose(pf);
    57. pf = NULL;
    58. }
    59. void InitSeqList(SeqList* ps)
    60. {
    61. ps->emp = (Employee*)malloc(sizeof(Employee) * 4);
    62. if (ps->emp == NULL)
    63. {
    64. perror("InitSeqList::malloc");
    65. return;
    66. }
    67. ps->size = 0;
    68. ps->capacity = 4;
    69. LoadSeqList(ps);
    70. }
    71. //菜单函数
    72. void Meau(void)
    73. {
    74. printf("--------------------------------\n");
    75. printf("--- 欢迎来到员工工资管理系统 ---\n");
    76. printf("--------------------------------\n");
    77. printf("---- 0.退出程序 ----\n");
    78. printf("---- 1.增加工资信息 ----\n");
    79. printf("---- 2.删除工资信息 ----\n");
    80. printf("---- 3.按名字查工资 ----\n");
    81. printf("---- 4.修改工资信息 ----\n");
    82. printf("---- 5.按照工资排序 ----\n");
    83. printf("---- 6.按照工号排序 ----\n");
    84. printf("---- 7.计算员工工资 ----\n");
    85. printf("---- 8.打印工资信息 ----\n");
    86. printf("---- 9.统计员工人数 ----\n");
    87. printf("-------------------------------\n");
    88. }
    89. void SaveSeqList(SeqList* ps)
    90. {
    91. FILE* pf = fopen("D:\\桌面\\test.txt", "wb");
    92. if (pf == NULL)
    93. {
    94. perror("LoadSeqList::fopen");
    95. return;
    96. }
    97. for (int i = 0; i < ps->size; i++)
    98. {
    99. fwrite(ps->emp + i, sizeof(Employee), 1, pf);
    100. }
    101. fclose(pf);
    102. pf = NULL;
    103. }
    104. void InitEmployee(Employee* ps, int i)
    105. {
    106. printf("请输入第%d位待插入的员工工资信息:\n",i);
    107. printf("请输入员工姓名:>");
    108. scanf("%s", ps->name);
    109. printf("请输入员工工号:>");
    110. scanf("%s", ps->id);
    111. printf("请输入员工的基本工资:>");
    112. scanf("%lf", &(ps->InitWages));
    113. printf("请输入员工的奖金:>");
    114. scanf("%lf", &(ps->bonus));
    115. printf("请输入员工的扣款:>");
    116. scanf("%lf", &(ps->deduct));
    117. printf("请输入员工的税款:>");
    118. scanf("%lf", &(ps->taxes));
    119. }
    120. void AddSeqList(SeqList* ps, Employee temp)
    121. {
    122. CheckCapacity(ps);
    123. ps->emp[ps->size] = temp;
    124. ps->size++;
    125. printf("增加成功.\n");
    126. }
    127. int FindByName(SeqList* ps,char* name)
    128. {
    129. for (int i = 0; i < ps->size; i++)
    130. {
    131. if (strcmp(name, ps->emp[i].name) == 0)
    132. {
    133. return i;
    134. }
    135. }
    136. return -1;
    137. }
    138. void DelSeqList(SeqList* ps)
    139. {
    140. if (ps->size == 0)
    141. {
    142. printf("当前员工总数为0,无法删除.\n");
    143. }
    144. char name[20] = { 0 };
    145. printf("请输入您要删除的员工信息的员工姓名:>");
    146. scanf("%s", name);
    147. int pos = FindByName(ps,name);
    148. if (pos == -1)
    149. {
    150. printf("当前系统中不存在名字为%s的员工.\n", name);
    151. return;
    152. }
    153. else
    154. {
    155. int begin = pos + 1;
    156. while (begin < ps->size)
    157. {
    158. ps->emp[begin -1] = ps->emp[begin];
    159. begin++;
    160. }
    161. ps->size--;
    162. }
    163. printf("删除成功.\n");
    164. }
    165. void SearByName(SeqList* ps)
    166. {
    167. char name[20] = { 0 };
    168. printf("请输入您要查询的员工信息的员工姓名:>");
    169. scanf("%s", name);
    170. int pos = FindByName(ps, name);
    171. if (pos == -1)
    172. {
    173. printf("当前系统中不存在名字为%s的员工.\n", name);
    174. return;
    175. }
    176. else
    177. {
    178. printf("%-20s %-20s %-10s %-10s %-10s %-10s %-10s %-10s\n", "员工姓名", "员工工号", "基本工资", "奖金", "扣款", "应发工资", "税款", "实发工资");
    179. printf("%-20s %-20s %-10.2lf %-10.2lf %-10.2lf %-10.2lf %-10.2lf %-10.2lf\n", \
    180. ps->emp[pos].name, ps->emp[pos].id, ps->emp[pos].InitWages, ps->emp[pos].bonus, ps->emp[pos].deduct, ps->emp[pos].NextWages, ps->emp[pos].taxes, ps->emp[pos].FinaWages);
    181. }
    182. }
    183. void ModifySeqList(SeqList* ps)
    184. {
    185. char name[20] = { 0 };
    186. printf("请输入您要修改的员工信息的员工姓名:>");
    187. scanf("%s", name);
    188. int pos = FindByName(ps, name);
    189. if (pos == -1)
    190. {
    191. printf("当前系统中不存在名字为%s的员工.\n", name);
    192. return;
    193. }
    194. char choice[20] = { 0 };
    195. rechoice:
    196. printf("请输入你要修改的信息项目名称");
    197. printf("(提示:您可选择输入员工工号,基本工资,奖金,扣款,税款):>");
    198. scanf("%s", choice);
    199. printf("请输入修改后的该信息项目值:>");
    200. if (strcmp(choice, "员工工号") == 0)
    201. {
    202. scanf("%s", ps->emp[pos].id);
    203. }
    204. else if (strcmp(choice, "基本工资") == 0)
    205. {
    206. scanf("%lf", &(ps->emp[pos].InitWages));
    207. }
    208. else if (strcmp(choice, "奖金") == 0)
    209. {
    210. scanf("%lf", &(ps->emp[pos].bonus));
    211. }
    212. else if (strcmp(choice, "扣款") == 0)
    213. {
    214. scanf("%lf", &(ps->emp[pos].deduct));
    215. }
    216. else if (strcmp(choice, "税款") == 0)
    217. {
    218. scanf("%lf", &(ps->emp[pos].taxes));
    219. }
    220. else
    221. {
    222. printf("请在提示中给出的选项中做出选择!\n");
    223. goto rechoice;
    224. }
    225. printf("修改成功.\n");
    226. }
    227. void Swap(Employee* a, Employee* b)
    228. {
    229. Employee temp = *a;
    230. *a = *b;
    231. *b = temp;
    232. }
    233. void QsortByFinaWages(SeqList* ps, int begin, int end)
    234. {
    235. if (begin >= end)
    236. {
    237. return;
    238. }
    239. int keyi = begin;
    240. int left = begin, right = end;
    241. while (left < right)
    242. {
    243. while (left < right && ps->emp[right].FinaWages <= ps->emp[keyi].FinaWages)
    244. {
    245. right--;
    246. }
    247. while (left < right && ps->emp[left].FinaWages >= ps->emp[keyi].FinaWages)
    248. {
    249. left++;
    250. }
    251. Swap(&(ps->emp[left]), &(ps->emp[right]));
    252. }
    253. int meeti = left;
    254. Swap(&(ps->emp[keyi]), &(ps->emp[meeti]));
    255. QsortByFinaWages(ps, begin, meeti - 1);
    256. QsortByFinaWages(ps, meeti+1, end);
    257. }
    258. void ShellSortById(SeqList* ps)
    259. {
    260. int gap = ps->size;
    261. while (gap > 1)
    262. {
    263. gap = (gap / 3 + 1);
    264. for (int i = 0; i < ps->size - gap; i++)
    265. {
    266. int end = i;
    267. Employee temp = ps->emp[i + gap];
    268. while (end >= 0)
    269. {
    270. if (strcmp(ps->emp[end].id , temp.id)>0)
    271. {
    272. ps->emp[end + gap] = ps->emp[end];
    273. end -= gap;
    274. }
    275. else
    276. {
    277. break;
    278. }
    279. }
    280. ps->emp[end + gap] = temp;
    281. }
    282. }
    283. }
    284. void CountSeqList(SeqList* ps)
    285. {
    286. for (int i = 0; i < ps->size; i++)
    287. {
    288. ps->emp[i].NextWages = ps->emp[i].InitWages + ps->emp[i].bonus - ps->emp[i].deduct;
    289. ps->emp[i].FinaWages = ps->emp[i].NextWages - ps->emp[i].taxes;
    290. }
    291. }
    292. void PrintSeqList(SeqList* ps)
    293. {
    294. printf("%-20s %-20s %-10s %-10s %-10s %-10s %-10s %-10s\n", "员工姓名", "员工工号", "基本工资", "奖金", "扣款", "应发工资","税款","实发工资");
    295. for (int i = 0; i < ps->size; i++)
    296. {
    297. printf("%-20s %-20s %-10.2lf %-10.2lf %-10.2lf %-10.2lf %-10.2lf %-10.2lf\n",\
    298. ps->emp[i].name,ps->emp[i].id, ps->emp[i].InitWages, ps->emp[i].bonus, ps->emp[i].deduct,ps->emp[i].NextWages,ps->emp[i].taxes,ps->emp[i].FinaWages);
    299. }
    300. }
    301. int main()
    302. {
    303. int input = 0;
    304. SeqList ST;
    305. InitSeqList(&ST);
    306. do//先执行一次
    307. {
    308. Meau();
    309. printf("请输入您的选择(提示:请在0-9之间选择):>");
    310. scanf("%d", &input);
    311. switch (input)
    312. {
    313. case 0:
    314. printf("欢迎您的使用,即将退出程序.\n");
    315. SaveSeqList(&ST);
    316. break;
    317. case 1:
    318. printf("********增加工资信息.********\n");
    319. int nums = 0;
    320. printf("请输入您要增加的员工信息的员工数量:>");
    321. scanf("%d", &nums);
    322. Employee temp = { 0 };
    323. for (int i = 1; i <= nums; i++)
    324. {
    325. InitEmployee(&temp,i);
    326. AddSeqList(&ST,temp);
    327. }
    328. CountSeqList(&ST);
    329. break;
    330. case 2:
    331. printf("********删除工资信息.********\n");
    332. DelSeqList(&ST);
    333. break;
    334. case 3:
    335. printf("********查询工资信息.********\n");
    336. SearByName(&ST);
    337. break;
    338. case 4:
    339. printf("********修改工资信息.********\n");
    340. ModifySeqList(&ST);
    341. CountSeqList(&ST);
    342. break;
    343. case 5:
    344. printf("********按照工资排序.(从高到低)********\n");
    345. QsortByFinaWages(&ST,0,ST.size);
    346. PrintSeqList(&ST);
    347. break;
    348. case 6:
    349. printf("********按照工号排序.(从小到大)********\n");
    350. ShellSortById(&ST);
    351. PrintSeqList(&ST);
    352. break;
    353. case 7:
    354. printf("********计算员工工资********\n");
    355. CountSeqList(&ST);
    356. printf("计算成功.\n");
    357. break;
    358. case 8:
    359. printf("********打印工资信息********\n");
    360. PrintSeqList(&ST);
    361. break;
    362. case 9:
    363. printf("********统计员工人数********\n");
    364. printf("当前系统人数:%d\n", ST.size);
    365. default:
    366. printf("********输入错误,请重新输入********\n");
    367. break;
    368. }
    369. } while (input);
    370. }

    17.效果预览图

     

    类似的,下面为学生信息管理系统 

    1. #define _CRT_SECURE_NO_WARNINGS 1
    2. #include<stdio.h>
    3. #include<stdlib.h>
    4. #include<string.h>
    5. typedef struct Student
    6. {
    7. char name[20];
    8. char id[20];
    9. float ChiScore;
    10. float MatScore;
    11. float EngScore;
    12. float SumScore;
    13. }Student;
    14. typedef struct SeqList
    15. {
    16. Student* stu;
    17. int size;
    18. int capacity;
    19. }SeqList;
    20. void meau1(void)
    21. {
    22. printf("--------------------------------\n");
    23. printf("--- 欢迎使用学生信息管理系统 ---\n");
    24. printf("--------------------------------\n");
    25. printf("---- 0.退出程序 ----\n");
    26. printf("---- 1.录入学生信息 ----\n");
    27. printf("---- 2.删除学生信息 ----\n");
    28. printf("---- 3.查询指定课程 ----\n");
    29. printf("---- 4.查询指定学生 ----\n");
    30. printf("---- 5.修改学生信息 ----\n");
    31. printf("---- 6.按照学号排序 ----\n");
    32. printf("---- 7.按照总分排序 ----\n");
    33. printf("---- 8.统计学生总数 ----\n");
    34. printf("---- 9.打印学生信息 ----\n");
    35. printf("--------------------------------\n");
    36. }
    37. //case -1 初始化: 初始化函数(3)
    38. void CheckCapacity(SeqList* ps)
    39. {
    40. if (ps->size == ps->capacity)
    41. {
    42. int newcapacity = 2 * ps->capacity;
    43. Student* temp = (Student*)realloc(ps->stu, sizeof(Student) * newcapacity);
    44. if (temp == NULL)
    45. {
    46. perror("CheckCapacity::realloc:>");
    47. return;
    48. }
    49. ps->capacity = newcapacity;
    50. ps->stu = temp;
    51. printf("扩容成功.\n");
    52. }
    53. }
    54. void LoadSeqList(SeqList* ps)
    55. {
    56. FILE* pf = fopen("D:\\桌面\\test.txt", "rb");
    57. if (pf == NULL)
    58. {
    59. perror("LoadSeqList::fopen:>");
    60. return;
    61. }
    62. Student temp = { 0 };
    63. while (fread(&temp, sizeof(Student), 1, pf))
    64. {
    65. CheckCapacity(ps);
    66. ps->stu[ps->size] = temp;
    67. ps->size++;
    68. }
    69. fclose(pf);
    70. pf = NULL;
    71. }
    72. void InitSeqList(SeqList* ps)
    73. {
    74. ps->stu = (Student*)malloc(sizeof(Student) * 4);
    75. if (ps->stu == NULL)
    76. {
    77. perror("InitSeqList::malloc:>");
    78. return;
    79. }
    80. ps->capacity = 4;
    81. ps->size = 0;
    82. LoadSeqList(ps);
    83. }
    84. //case 0 退出程序:保存数据到文件函数(1)
    85. void SaveSeqList(SeqList* ps)
    86. {
    87. FILE* pf = fopen("D:\\桌面\\test.txt", "wb");
    88. if (pf == NULL)
    89. {
    90. perror("LoadSeqList::fopen:>");
    91. return;
    92. }
    93. for (int i = 0; i < ps->size; i++)
    94. {
    95. fwrite(ps->stu + i, sizeof(Student), 1, pf);
    96. }
    97. fclose(pf);
    98. pf = NULL;
    99. }
    100. //case 1:录入学生信息 装配和插入函数(2)
    101. void InitStudent(Student* ps,int i)
    102. {
    103. printf("请输入第%d个待录入的学生信息:\n", i);
    104. printf("请输入学生的名字:>");
    105. scanf("%s", ps->name);
    106. printf("请输入学生的学号:>");
    107. scanf("%s", ps->id);
    108. printf("请输入学生的语文成绩(0-100):>");
    109. scanf("%f", &(ps->ChiScore));
    110. printf("请输入学生的数学成绩(0-100):>");
    111. scanf("%f", &(ps->MatScore));
    112. printf("请输入学生的英语成绩(0-100):>");
    113. scanf("%f", &(ps->EngScore));
    114. ps->SumScore = ps->ChiScore + ps->MatScore + ps->EngScore;
    115. }
    116. void AddSeqList(SeqList* ps,Student temp)
    117. {
    118. CheckCapacity(ps);
    119. ps->stu[ps->size] = temp;
    120. ps->size++;
    121. }
    122. //case 2:删除学生信息 菜单函数,定位和删除函数(4)
    123. void meau2(void)
    124. {
    125. printf("-- 1.按照名字查找 --\n");
    126. printf("-- 2.按照学号查找 --\n");
    127. }
    128. //找得到返回下标,找不到返回-1
    129. int FindByName(SeqList* ps, const char* name)
    130. {
    131. for (int i = 0; i < ps->size; i++)
    132. {
    133. if (strcmp(ps->stu[i].name, name) == 0)
    134. {
    135. return i;
    136. }
    137. }
    138. return -1;
    139. }
    140. int FindById(SeqList* ps, const char* id)
    141. {
    142. for (int i = 0; i < ps->size; i++)
    143. {
    144. if (strcmp(ps->stu[i].id, id) == 0)
    145. {
    146. return i;
    147. }
    148. }
    149. return -1;
    150. }
    151. void DelSeqList(SeqList* ps)
    152. {
    153. if (ps->size == 0)
    154. {
    155. printf("当前学生总数为0,无法删除.\n");
    156. return;
    157. }
    158. meau2();
    159. int choice1 = 0;
    160. rechoice1:
    161. printf("请根据您要按何种方式查找到要删除的学生,输入相应的编号:>");
    162. scanf("%d", &choice1);
    163. int pos = 0;
    164. if (choice1 == 1)
    165. {
    166. char name[20] = { 0 };
    167. printf("请输入您要删除学生的学生姓名:>");
    168. scanf("%s", name);
    169. pos = FindByName(ps, name);
    170. }
    171. else if (choice1 == 2)
    172. {
    173. char id[20] = { 0 };
    174. printf("请输入您要删除学生的学生学号:>");
    175. scanf("%s", id);
    176. pos = FindById(ps, id);
    177. }
    178. else
    179. {
    180. printf("选择错误,请重新选择(提示:请在1-2中选择).\n");
    181. goto rechoice1;
    182. }
    183. if (pos == -1)
    184. {
    185. printf("您现在要删除的学生不存在当前学生信息管理系统中,请重新选择.\n");
    186. goto rechoice1;
    187. }
    188. else
    189. {
    190. int begin = pos + 1;
    191. while (begin < ps->size)
    192. {
    193. ps->stu[begin - 1] = ps->stu[begin];
    194. begin++;
    195. }
    196. ps->size--;
    197. printf("删除成功.\n");
    198. }
    199. }
    200. //case 3: 查询指定课程 菜单函数,定位和杂碎函数(10)
    201. void meau3(void)
    202. {
    203. printf("-- 1.语文 --\n");
    204. printf("-- 2.数学 --\n");
    205. printf("-- 3.英语 --\n");
    206. }
    207. void Swap(char* buff1, char* buff2,int width)
    208. {
    209. while (width--)
    210. {
    211. char temp = *buff1;
    212. *buff1 = *buff2;
    213. *buff2 = temp;
    214. buff1++;
    215. buff2++;
    216. }
    217. }
    218. int cmp_struct_by_ChiScore(const void* e1, const void* e2)
    219. {
    220. return ((Student*)e2)->ChiScore - ((Student*)e1)->ChiScore;
    221. }
    222. int cmp_struct_by_MatScore(const void* e1, const void* e2)
    223. {
    224. return ((Student*)e2)->MatScore - ((Student*)e1)->MatScore;
    225. }
    226. int cmp_struct_by_EngScore(const void* e1, const void* e2)
    227. {
    228. return ((Student*)e2)->EngScore - ((Student*)e1)->EngScore;
    229. }
    230. void BubbleSort(void* base, int size, int width, float (*cmp)(const void*, const void*))
    231. {
    232. int flag = 0;
    233. for (int i = 0; i < size - 1; i++)
    234. {
    235. for (int j = 0; j < size-1- i; j++)
    236. {
    237. if (cmp((char*)base + j * width, (char*)base + (j + 1) * width) > 0)
    238. {
    239. Swap((char*)base + j * width, (char*)base + (j + 1) * width, width);
    240. flag = 1;
    241. }
    242. }
    243. if (flag == 0)
    244. {
    245. break;
    246. }
    247. }
    248. }
    249. void DisPlayByChiScore(SeqList* ps)
    250. {
    251. printf("%-20s %-20s %-20s %-20s\n", "姓名", "学号", "语文成绩", "语文成绩排名");
    252. for (int i = 0; i < ps->size; i++)
    253. {
    254. printf("%-20s %-20s %-20.2f %-20d\n", ps->stu[i].name, ps->stu[i].id, ps->stu[i].ChiScore, i + 1);
    255. }
    256. }
    257. void DisPlayByMatScore(SeqList* ps)
    258. {
    259. printf("%-20s %-20s %-20s %-20s\n", "姓名", "学号", "数学成绩", "数学成绩排名");
    260. for (int i = 0; i < ps->size; i++)
    261. {
    262. printf("%-20s %-20s %-20.2f %-20d\n", ps->stu[i].name, ps->stu[i].id, ps->stu[i].MatScore, i + 1);
    263. }
    264. }
    265. void DisPlayByEngScore(SeqList* ps)
    266. {
    267. printf("%-20s %-20s %-20s %-20s\n", "姓名", "学号", "英语成绩", "英语成绩排名");
    268. for (int i = 0; i < ps->size; i++)
    269. {
    270. printf("%-20s %-20s %-20.2f %-20d\n", ps->stu[i].name, ps->stu[i].id, ps->stu[i].EngScore, i + 1);
    271. }
    272. }
    273. void SearByCourse(SeqList* ps)
    274. {
    275. if (ps->size == 0)
    276. {
    277. printf("当前学生总数为0,无法修改.\n");
    278. return;
    279. }
    280. meau3();
    281. int choice2 = 0;
    282. rechoice2:
    283. printf("请根据您要查询课程的名称,选择相应的编号:>");
    284. scanf("%d", &choice2);
    285. float sum = 0.00;
    286. int count1 = 0, count2 = 0;
    287. printf("\t\t***********查询课程结果***********\n\n");
    288. if (choice2 == 1)
    289. {
    290. for (int i = 0; i < ps->size; i++)
    291. {
    292. sum += ps->stu[i].ChiScore;
    293. if (ps->stu[i].ChiScore < 60)
    294. {
    295. count1++;
    296. }
    297. else if (ps->stu[i].ChiScore < 90)
    298. {
    299. count2++;
    300. }
    301. }
    302. BubbleSort(ps->stu, ps->size, sizeof(Student), cmp_struct_by_ChiScore);
    303. DisPlayByChiScore(ps);
    304. }
    305. else if (choice2 == 2)
    306. {
    307. for (int i = 0; i < ps->size; i++)
    308. {
    309. sum += ps->stu[i].MatScore;
    310. if (ps->stu[i].MatScore < 60)
    311. {
    312. count1++;
    313. }
    314. else if (ps->stu[i].MatScore < 90)
    315. {
    316. count2++;
    317. }
    318. }
    319. BubbleSort(ps->stu, ps->size, sizeof(Student), cmp_struct_by_MatScore);
    320. DisPlayByMatScore(ps);
    321. }
    322. else if (choice2 == 3)
    323. {
    324. for (int i = 0; i < ps->size; i++)
    325. {
    326. sum += ps->stu[i].EngScore;
    327. if (ps->stu[i].EngScore < 60)
    328. {
    329. count1++;
    330. }
    331. else if (ps->stu[i].EngScore < 90)
    332. {
    333. count2++;
    334. }
    335. }
    336. BubbleSort(ps->stu, ps->size, sizeof(Student), cmp_struct_by_EngScore);
    337. DisPlayByEngScore(ps);
    338. }
    339. else
    340. {
    341. printf("选择错误,请重新选择(提示:请在1-3中选择).\n");
    342. goto rechoice2;
    343. }
    344. printf("\n\n% -20s % -20s % -20s % -20s % -20s\n", "不及格人数(0-60)", "及格人数(60-100)", "良好人数(60-90)", "优秀人数(90-100)","平均分");
    345. printf("%-20d %-20d %-20d %-20d %-20.2f\n", count1, ps->size - count1, count2, ps->size - count1 - count2, sum / ps->size);
    346. }
    347. //case 4:查询指定学生
    348. void SearByStudent(SeqList* ps)
    349. {
    350. if (ps->size == 0)
    351. {
    352. printf("当前学生总数为0,无法查询.\n");
    353. return;
    354. }
    355. meau2();
    356. int choice3 = 0;
    357. rechoice3:
    358. printf("请根据您要按何种方式查找学生,输入相应的编号:>");
    359. scanf("%d", &choice3);
    360. int pos = 0;
    361. if (choice3 == 1)
    362. {
    363. char name[20] = { 0 };
    364. printf("请输入您要查询学生的学生姓名:>");
    365. scanf("%s", name);
    366. pos = FindByName(ps, name);
    367. }
    368. else if (choice3 == 2)
    369. {
    370. char id[20] = { 0 };
    371. printf("请输入您要查询学生的学生学号:>");
    372. scanf("%s", id);
    373. pos = FindById(ps, id);
    374. }
    375. else
    376. {
    377. printf("选择错误,请重新选择(提示:请在1-2中选择).\n");
    378. goto rechoice3;
    379. }
    380. if (pos == -1)
    381. {
    382. printf("您现在要查询的学生不存在当前学生信息管理系统中,请重新选择.\n");
    383. goto rechoice3;
    384. }
    385. else
    386. {
    387. printf("\t\t***********查询学生结果***********\n");
    388. printf("%-20s %-20s %-20s %-20s %-20s %-20s %-20s\n","姓名","学号", "语文成绩", "数学成绩", "英语成绩", "总成绩", "总成绩排名");
    389. printf("%-20s %-20s %-20.2f %-20.2f %-20.2f %-20.2f %-20d\n", ps->stu[pos].name, ps->stu[pos].id, \
    390. ps->stu[pos].ChiScore, ps->stu[pos].MatScore, ps->stu[pos].EngScore, ps->stu[pos].SumScore, pos + 1);
    391. }
    392. }
    393. //case 5: 修改学生成绩 -菜单函数和修改函数 -先找到这个学生,再进行修改
    394. void ModSeqList(SeqList* ps)
    395. {
    396. if (ps->size == 0)
    397. {
    398. printf("当前学生总数为0,无法修改.\n");
    399. return;
    400. }
    401. meau2();
    402. int choice4 = 0;
    403. rechoice4:
    404. printf("请根据您要按何种方式查找到要修改的学生,输入相应的编号:>");
    405. scanf("%d", &choice4);
    406. int pos = 0;
    407. if (choice4 == 1)
    408. {
    409. char name[20] = { 0 };
    410. printf("请输入您要修改的学生信息的学生姓名:>");
    411. scanf("%s", name);
    412. pos = FindByName(ps, name);
    413. }
    414. else if (choice4 == 2)
    415. {
    416. char id[20] = { 0 };
    417. printf("请输入您要修改的学生信息的学生学号:>");
    418. scanf("%s", id);
    419. pos = FindById(ps, id);
    420. }
    421. else
    422. {
    423. printf("选择错误(提示:请在1-2中选择).\n");
    424. goto rechoice4;
    425. }
    426. if (pos == -1)
    427. {
    428. printf("您现在要查询的学生不存在当前学生信息管理系统中,请重新选择.\n");
    429. goto rechoice4;
    430. }
    431. else
    432. {
    433. meau3();
    434. int input = 0;
    435. again:
    436. printf("请根据您要修改的课程成绩的课程名称,选择相应的编号:>");
    437. scanf("%d", &input);
    438. printf("请输入修改后的值:>");
    439. if (input == 1)
    440. {
    441. scanf("%f", &(ps->stu[pos].ChiScore));
    442. }
    443. else if (input == 2)
    444. {
    445. scanf("%f", &(ps->stu[pos].EngScore));
    446. }
    447. else if (input == 3)
    448. {
    449. scanf("%f", &(ps->stu[pos].EngScore));
    450. }
    451. else
    452. {
    453. printf("选择错误,请重新选择 (提示:请在1-3中选择):>");
    454. goto again;
    455. }
    456. printf("修改成功.\n");
    457. }
    458. }
    459. //case 6: 按照学号排序 -排升序
    460. void Swap2(Student* s1, Student* s2)
    461. {
    462. Student temp = *s1;
    463. *s1 = *s2;
    464. *s2 = temp;
    465. }
    466. void QsortById(SeqList* ps, int begin, int end)
    467. {
    468. if (begin >= end)
    469. {
    470. return;
    471. }
    472. int keyi = begin;
    473. int left = begin, right = end;
    474. while (left < right)
    475. {
    476. while (left < right && strcmp(ps->stu[right].id, ps->stu[keyi].id)>0)
    477. {
    478. right--;
    479. }
    480. while (left < right && strcmp(ps->stu[left].id, ps->stu[keyi].id) <= 0)
    481. {
    482. left++;
    483. }
    484. Swap2(&(ps->stu[left]), &(ps->stu[right]));
    485. }
    486. int meeti = left;
    487. Swap2(&(ps->stu[meeti]), &(ps->stu[keyi]));
    488. QsortById(ps, begin, meeti - 1);
    489. QsortById(ps, meeti + 1, end);
    490. }
    491. //case 7: 按照总成绩排序-排降序
    492. void ShellSortBySumScore(SeqList* ps)
    493. {
    494. int gap = ps->size;
    495. while (gap > 1)
    496. {
    497. gap = (gap / 3 + 1);
    498. for (int i = 0; i < ps->size - gap; i++)
    499. {
    500. int end = i;
    501. Student temp = ps->stu[end + gap];
    502. while (end >= 0)
    503. {
    504. if (temp.SumScore > ps->stu[end].SumScore)
    505. {
    506. ps->stu[end + gap] = ps->stu[end];
    507. end--;
    508. }
    509. else
    510. {
    511. break;
    512. }
    513. }
    514. ps->stu[end + gap] = temp;
    515. }
    516. }
    517. }
    518. //case 9: 打印学生信息
    519. void PrintSeqList(SeqList* ps)
    520. {
    521. if (ps->size == 0)
    522. {
    523. printf("当前学生总数为0,无法打印.\n");
    524. return;
    525. }
    526. printf("%-20s %-20s %-20s %-20s %-20s %-20s %-20s\n", "姓名", "学号", "语文成绩", "数学成绩", "英语成绩", "总成绩", "排名");
    527. for (int i = 0; i < ps->size; i++)
    528. {
    529. printf("%-20s %-20s %-20.2f %-20.2f %-20.2f %-20.2f %-20d\n", ps->stu[i].name, ps->stu[i].id, \
    530. ps->stu[i].ChiScore, ps->stu[i].MatScore, ps->stu[i].EngScore, ps->stu[i].SumScore, i+1);
    531. }
    532. }
    533. int main()
    534. {
    535. SeqList ST;
    536. InitSeqList(&ST);
    537. int input = 0;
    538. do
    539. {
    540. meau1();
    541. printf("请输入您的选择(提示:只能在0-9之间做选择):>");
    542. scanf("%d", &input);
    543. switch (input)
    544. {
    545. case 0:
    546. printf("\t******感谢您的使用,即将退出程序******\n");
    547. SaveSeqList(&ST);
    548. break;
    549. case 1:
    550. printf("\t******录入学生信息******\n");
    551. int nums = 0;
    552. printf("请输入您要录入的学生个数:>");
    553. scanf("%d", &nums);
    554. Student temp = { 0 };
    555. for (int i = 1; i <= nums; i++)
    556. {
    557. InitStudent(&temp, i);
    558. AddSeqList(&ST, temp);
    559. }
    560. printf("录入成功.\n");
    561. break;
    562. case 2:
    563. printf("\t******删除学生信息******\n");
    564. DelSeqList(&ST);
    565. break;
    566. case 3:
    567. printf("\t******查询指定课程******\n");
    568. SearByCourse(&ST);
    569. break;
    570. case 4:
    571. printf("\t******查询指定学生******\n");
    572. SearByStudent(&ST);
    573. break;
    574. case 5:
    575. printf("\t******修改学生信息******\n");
    576. ModSeqList(&ST);
    577. break;
    578. case 6:
    579. printf("\t******按照学号排序 (由小到大)******\n");
    580. QsortById(&ST, 0, ST.size);
    581. PrintSeqList(&ST);
    582. break;
    583. case 7:
    584. printf("\t******按照总分排序 (由高到低)******\n");
    585. ShellSortBySumScore(&ST);
    586. PrintSeqList(&ST);
    587. break;
    588. case 8:
    589. printf("\t******统计学生总数******\n");
    590. printf("当前学生总数:%d\n", ST.size);
    591. break;
    592. case 9:
    593. printf("\t******打印学生信息******\n");
    594. PrintSeqList(&ST);
    595. break;
    596. default:
    597. printf("选择错误,请重新选择(提示:请在0-9中选择):>");
    598. break;
    599. }
    600. } while (input);
    601. }

  • 相关阅读:
    【漏洞复现】weblogic-10.3.6-‘wls-wsat‘-XMLDecoder反序列化(CVE-2017-10271)
    [附源码]计算机毕业设计JAVA疫苗接种管理系统
    邀请加入团队
    使用docker安装elasticsearch 7.4.2
    点云的区域增长聚类算法 (附open3d python代码)
    【Linux】nohub指令--终端退出后命令仍旧执行
    11.27学术报告听讲笔记
    【51单片机】DS18B20(江科大)
    内部类_Java
    使用RabbitMq实现延时队列
  • 原文地址:https://blog.csdn.net/qq_64428099/article/details/125381809