学生成绩管理系统V1.0(4分)
题目内容:
某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,用一维数组作函数参数编程实现如下学生成绩管理:
(1)录入每个学生的学号和考试成绩;
(2)计算课程的总分和平均分;
(3)按成绩由高到低排出名次表;
(4)按学号由小到大排出成绩表;
(5)按学号查询学生排名及其考试成绩;
(6)按优秀(90100)、良好(8089)、中等(7079)、及格(6069)、不及格(0~59)5个类别,统计每个类别的人数以及所占的百分比;
(7)输出每个学生的学号、考试成绩。
程序运行结果示例:
Input student number(n<30):
6↙
Management for Students’ scores
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 Input your choice:
1↙
Input student’s ID, name and score:
11003001 87↙
11003005 98↙
11003003 75↙
11003002 48↙
11003004 65↙
11003006 100↙
Management for Students’ scores
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 Input your choice:
2↙
sum=473,aver=78.83
Management for Students’ scores
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 Input your choice:
3↙
Sort in descending order by score:
11003006 100
11003005 98
11003001 87
11003003 75
11003004 65
11003002 48
Management for Students’ scores
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 Input your choice:
4↙
Sort in ascending order by number:
11003001 87
11003002 48
11003003 75
11003004 65
11003005 98
11003006 100
Management for Students’ scores
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 Input your choice:
5↙
Input the number you want to search:
11003004
11003004 65
Management for Students’ scores
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 Input your choice:
6↙
<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%
Management for Students’ scores
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 Input your choice:
7↙
11003001 87
11003002 48
11003003 75
11003004 65
11003005 98
11003006 100
Management for Students’ scores
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 Input your choice:
8↙
Input error!
Management for Students’ scores
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 Input your choice:
0↙
End of program!
输入格式:
( 1 )录入学生的人数:
**输入数据格式:"%d"
**提示信息:"Input student number(n<30):\n"
( 2 )录入每个学生的学号和考试成绩:
**输入数据格式:"%ld%f"
**提示信息:"Input student's ID, name and score:\n"
输出格式:
菜单项的输出显示:
Management for Students’ scores
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 Input your choice:
计算课程的总分和平均分:
**输出总分与平均分格式:"sum=%.0f,aver=%.2f\n"
按成绩由高到低排出名次表:
**输出格式:"%ld\t%.0f\n"
**提示信息:"Sort in descending order by score:\n"
按学号由小到大排出成绩表:
**输出格式:"%ld\t%.0f\n"
**提示信息:"Sort in ascending order by number:\n"
按学号查询学生排名及其考试成绩:
**如果未查到此学号的学生,提示信息:"Not found!\n"
**如果查询到该学生,输出格式:"%ld\t%.0f\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"
为避免出现格式错误,请直接拷贝粘贴题目中给的格式字符串和提示信息到你的程序中。
时间限制:500ms内存限制:32000kb
C语言实现:
#include <stdio.h>
void Y(void);
void Input(long a[], int b[], int n);
void Caculate(long a[], int b[], int n);
void score(long a[], int b[], int n);
void number(long a[], int b[], int n);
void Search(long a[], int b[], int n);
void Statistic(long a[], int b[], int n);
int main()
{
int n, m;
long a[30];
int b[30];
printf("Input student number(n<30):\n");
scanf("%d", &n);
printf("Management for Students' scores\n"
"1.Input record\n"
"2.Caculate total and average score of course\n"
"3.Sort in descending order by score\n"
"4.Sort in ascending order by number\n"
"5.Search by number\n"
"6.Statistic analysis\n"
"7.List record\n"
"0.Exit\n"
"Please Input your choice:\n");
while(scanf("%d", &m) && m != 0)
{
switch(m)
{
case 1:printf("Input student's ID, name and score:\n");
Input(a, b, n);
break;
case 2:Caculate(a, b, n);
break;
case 3:printf("Sort in descending order by score:\n");
score(a, b, n);
break;
case 4:printf("Sort in ascending order by number:\n");
number(a, b, n);
break;
case 5:printf("Input the number you want to search:\n");
Search(a, b, n);
break;
case 6:Statistic(a, b, n);
break;
case 7:number(a, b, n);
break;
default:printf("Input error!\n");
}
Y();
}
printf("End of program!\n");
return 0;
}
void Y(void)
{
printf("Management for Students' scores\n"
"1.Input record\n"
"2.Caculate total and average score of course\n"
"3.Sort in descending order by score\n"
"4.Sort in ascending order by number\n"
"5.Search by number\n"
"6.Statistic analysis\n"
"7.List record\n"
"0.Exit\n"
"Please Input your choice:\n");
return ;
}
void Input(long a[], int b[], int n)
{
long i;
for(i=0;i<n;i++)
{
scanf("%ld%ld", &a[i], &b[i]);
}
return ;
}
void Caculate(long a[], int b[], int n)
{
float sum=0, aver;
int i;
for(i=0;i<n;i++)
{
sum = sum + b[i];
}
aver = sum / n;
printf("sum=%.0f,aver=%.2f\n", sum, aver);
return ;
}
void score(long a[], int b[], int n)
{
int i, term1, r;
long term2;
for(r=0;r<n;r++)
{
for(i=0;i<n-1;i++)
{
if(b[i]<b[i+1])
{
term1 = b[i];
b[i] = b[i+1];
b[i+1] = term1;
term2 = a[i];
a[i] = a[i+1];
a[i+1] = term2;
}
}
}
for(i=0;i<n;i++)
{
printf("%ld\t%.0f\n", a[i], (float)b[i]);
}
return ;
}
void number(long a[], int b[], int n)
{
int i, term1, r;
long term2;
for(r=0;r<n;r++)
{
for(i=0;i<n-1;i++)
{
if(a[i]>a[i+1])
{
term1 = b[i];
b[i] = b[i+1];
b[i+1] = term1;
term2 = a[i];
a[i] = a[i+1];
a[i+1] = term2;
}
}
}
for(i=0;i<n;i++)
{
printf("%ld\t%.0f\n", a[i], (float)b[i]);
}
return ;
}
void Search(long a[], int b[], int n)
{
long m;
int i;
scanf("%ld", &m);
for(i=0;i<n;i++)
{
if(a[i]%1000 == m%1000)
{
printf("%ld\t%.0f\n", a[i], (float)b[i]);
return ;
}
}
printf("Not found!\n");
return ;
}
void Statistic(long a[], int b[], int n)
{
int i;
int x1=0, x2=0, x3=0, x4=0, x5=0, x6=0;
for(i=0;i<n;i++)
{
if(b[i] < 60)
x1++;
else if(b[i] < 70)
x2++;
else if(b[i] < 80)
x3++;
else if(b[i] < 90)
x4++;
else if(b[i] < 100)
x5++;
else
x6++;
}
printf("<60\t%d\t%.2f%%\n", x1, (float)x1*100/(float)n);
printf("%d-%d\t%d\t%.2f%%\n", 60, 69, x2, (float)x2*100/(float)n);
printf("%d-%d\t%d\t%.2f%%\n", 70, 79, x3, (float)x3*100/(float)n);
printf("%d-%d\t%d\t%.2f%%\n", 80, 89, x4, (float)x4*100/(float)n);
printf("%d-%d\t%d\t%.2f%%\n", 90, 99, x5, (float)x5*100/(float)n);
printf("%d\t%d\t%.2f%%\n", 100, x6, (float)x6*100/(float)n);
return ;
}