代码修改

Cx330_ReadScore
Cx330 2 years ago
parent 90e8b13f94
commit 13bb2e47b1

@ -1,5 +1,3 @@
// 头文件的使用
#include<stdio.h> #include<stdio.h>
#include<stdlib.h> #include<stdlib.h>
#include<string.h> #include<string.h>
@ -48,7 +46,7 @@ int main(void)
int n = 0, m = 0; int n = 0, m = 0;
STU stu[STU_NUM]; STU stu[STU_NUM];
printf("Input student number(n<%d):", STU_NUM); printf("Input student number(n<%d):", STU_NUM);
scnaf("%d",&n); scanf("%d", &n);
printf("Input course number(m<=%d):", COURSE_NUM); printf("Input course number(m<=%d):", COURSE_NUM);
scanf("%d", &m); scanf("%d", &m);
while (1) while (1)
@ -91,7 +89,7 @@ int main(void)
case 13:ReadfromFile(stu, &n, &m); case 13:ReadfromFile(stu, &n, &m);
break; break;
case 0: printf("Are you sure you want to exit?(Y/N):"); case 0: printf("Are you sure you want to exit?(Y/N):");
printf("End of program!); printf("End of program!");
exit(0); exit(0);
default:printf("Input error!"); default:printf("Input error!");
} }
@ -128,7 +126,7 @@ void ReadScore(STU stu[],int n,int m)
{ {
int i, j; int i, j;
printf("Input student's ID ,name and score:\n"); printf("Input student's ID ,name and score:\n");
for(i=0,i<n;i++) //输入n个同学 for (i = 0; i < n; i++) //输入n个同学
{ {
scanf("%ld%s", &stu[i].num, stu[i].name); scanf("%ld%s", &stu[i].num, stu[i].name);
for (j = 0; j < m; j++) //输入m门成绩 for (j = 0; j < m; j++) //输入m门成绩
@ -240,7 +238,6 @@ void AsSortbyNum(STU stu[],int n,int m)
int i, j, k, t; int i, j, k, t;
for (i = 0; i < n - 1; i++) for (i = 0; i < n - 1; i++)
{ {
int i, j, k, t;
k = i; k = i;
for (j = i + 1; j < n; j++) for (j = i + 1; j < n; j++)
{ {
@ -323,7 +320,7 @@ void SearchbyName(STU stu[],int n,int m)
return; return;
} }
} }
printf("\nNot found!\n); printf("\nNot found!\n");
} }
//函数功能:统计各分数段的学生人数及所占的百分比 //函数功能:统计各分数段的学生人数及所占的百分比

Loading…
Cancel
Save