- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章C语言实现简易学生成绩管理系统由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,编程实现如下学生成绩管理:
(1)录入每个学生的学号和考试成绩; (2)计算课程的总分和平均分; (3)按成绩由高到低排出名次表; (4)按学号由小到大排出成绩表; (5)按学号查询学生排名及其考试成绩; (6)按优秀(90-100)、良好(80-89)、中等(70-79)、及格(60-69)、不及格(0-59)5个类别,统计每个类别的人数以及所占的百分比; (7)输出每个学生的学号、考试成绩,以及课程总分和平均分.
输入格式:
( 1 ) 录入学生的人数:
要求输入数据格式为:"%d" 提示信息为:“Input student number(n<30):\n” 。
( 2 )录入每个学生的学号和考试成绩:
要求输入数据格式为:"%ld%f" 提示信息为:“Input student's ID and score:\n” 。
输出格式:
1、菜单项的输出显示:
Management for Students' scores 1.Input record 2.Calculate 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=%.0f,aver=%.2f\n” 。
3、按成绩由高到低排出名次表:
要求输出格式为:"%ld\t%.0f\n" 提示信息为:“Sort in descending order by score:\n” 。
4、按学号由小到大排出成绩表:
要求输出格式为:"%ld\t%.0f\n" 提示信息为:“Sort in ascending order by number:\n” 。
5、按学号查询学生信息及其考试成绩(输出学号与成绩):
如果未查到此学号的学生,提示信息为:“Not found!\n”; 如果查询到该学生,要求输出格式为:"%ld\t%.0f\n" 。
6、按优秀(90-100)、良好(80-89)、中等(70-79)、及格(60-69)、不及格(0-59)5个类别,统计每个类别的人数以及所占的百分比:
成绩<60输出提示格式为:"<60\t%d\t%.2f%%\n"; 成绩=100输出格式为:"%d\t%d\t%.2f%%\n"; 其他要求输出百分比格式为:"%d-%d\t%d\t%.2f%%\n" 。
演示效果:
代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
//宏定义最大学生人数
#define stu_max 30
/*进行函数的全局声明*/
//获取学生人数
int
stu_num();
//显示菜单获取用户输入
char
menu_tips();
//获取学生学号,及本门考试成绩
void
stu_information(
long
num[],
float
score[],
int
n);
//计算输出课程的总分和平均分
void
sum_aver(
float
score[],
int
n);
//模块功能:交换两个长整型数据
void
exchange_long(
long
*a,
long
*b);
//模块功能:交换两个浮点型数据
void
exchange_float(
float
*a,
float
*b);
//按成绩由高到低输出名次表
void
output_score(
long
num[],
float
score[],
int
n);
//按学号从小到大排出成绩表
void
output_num(
long
num[],
float
score[],
int
n);
//查询输出学生信息及考试成绩:
void
query(
long
num[],
float
score[],
int
n);
//分数划界处理并输出
void
score_pro(
float
score[],
int
n);
//直接输出对应列表
void
output(
long
num[],
float
score[],
int
n);
//暂停清屏
void
clean();
int
main()
{
int
n,i;
long
num[stu_max];
float
score[stu_max];
n=stu_num();
while
(1)
{
i=menu_tips();
switch
(i)
{
case
'1'
:
printf
(
"1"
),stu_information(num,score,n),
system
(
"cls"
);
break
;
case
'2'
:
printf
(
"2"
),sum_aver(score,n),clean();
break
;
case
'3'
:
printf
(
"3"
),output_score(num,score,n),clean();
break
;
case
'4'
:
printf
(
"4"
),output_num(num,score,n),clean();
break
;
case
'5'
:
printf
(
"5"
),query(num,score,n),clean();
break
;
case
'6'
:
printf
(
"6"
),score_pro(score,n),clean();
break
;
case
'7'
:
printf
(
"7"
),output(num,score,n),clean();
break
;
case
'0'
:
printf
(
"0"
),
exit
(0);
break
;
default
:
printf
(
"Input error!\n"
),clean();
}
}
}
/*以下为函数功能模块*/
//获取学生人数
int
stu_num()
{
int
n;
printf
(
"Input student number(n<30):\n"
);
scanf
(
"%d"
,&n);
system
(
"cls"
);
return
n;
}
//显示菜单获取用户输入
char
menu_tips()
{
printf
(
" -----------------------------------------------------------\n"
);
printf
(
"| Management for Students' scores |\n"
);
printf
(
" -----------------------------------------------------------\n"
);
printf
(
"| 1.Input record |\n"
);
printf
(
"| 2.Calculate total and average score of course |\n"
);
printf
(
"| 3.Sort in descending order by score |\n"
);
printf
(
"| 4.Sort in ascending order by numbe |\n"
);
printf
(
"| 5.Search by number |\n"
);
printf
(
"| 6.Statistic analysis |\n"
);
printf
(
"| 7.List record |\n"
);
printf
(
"| 0.Exit |\n"
);
printf
(
" -----------------------------------------------------------\n"
);
printf
(
"\nPlease Input your choice:\n"
);
char
i;
i=getch();
return
i;
}
//获取学生学号,及本门考试成绩
void
stu_information(
long
num[],
float
score[],
int
n)
{
int
i;
printf
(
"\nInput student's ID and score:\n"
);
for
(i=0;i<n;i++)
scanf
(
"%ld%f"
,&num[i],&score[i]);
}
//计算输出课程的总分和平均分
void
sum_aver(
float
score[],
int
n)
{
int
i;
float
sum,aver;
for
(i=0,sum=0;i<n;i++)
sum+=score[i];
aver=sum/n;
printf
(
"\nsum=%.0f,aver=%.2f\n"
,sum,aver);
}
//模块功能:交换两个长整型数据
void
exchange_long(
long
*a,
long
*b)
{
long
t;
t=*a;
*a=*b;
*b=t;
}
//模块功能:交换两个浮点型数据
void
exchange_float(
float
*a,
float
*b)
{
float
t;
t=*a; *a=*b; *b=t;
}
//按成绩由高到低输出名次表
void
output_score(
long
num[],
float
score[],
int
n)
{
int
i,j;
for
(j=n-1;j>0;j--)
{
for
(i=0;i<j;i++)
if
(score[i]<score[i+1])
{
exchange_float(&score[i],&score[i+1]);
exchange_long(&num[i],&num[i+1]);
}
}
printf
(
"\nSort in descending order by score:"
);
output(num,score,n);
}
//按学号从小到大排出成绩表
void
output_num(
long
num[],
float
score[],
int
n)
{
int
i,j;
for
(j=n-1;j>0;j--)
{
for
(i=0;i<j;i++)
if
(num[i]>num[i+1])
{
exchange_float(&score[i],&score[i+1]);
exchange_long(&num[i],&num[i+1]);
}
}
output(num,score,n);
}
//查询输出学生信息及考试成绩:
void
query(
long
num[],
float
score[],
int
n)
{
printf
(
"\nEnter the ID to query:\n"
);
long
temp;
scanf
(
"%ld"
,&temp);
int
i;
for
(i=0;i<n;i++)
{
if
(num[i]==temp)
{
printf
(
"%ld\t%.0f\n"
,num[i],score[i]);
return
;
}
}
printf
(
"\nNot found!\n"
);
}
//分数划界处理并输出
void
score_pro(
float
score[],
int
n)
{
int
t[6]={0,0,0,0,0,0};
/*前五个分别对应优秀、良好、中等、及格、不及格五个类别
第六位存储100分的人数*/
int
i,m;
for
(i=0;i<n;i++)
{
if
(score[i]>=90&&score[i]<100) t[0]++;
if
(score[i]>=80&&score[i]<=89) t[1]++;
if
(score[i]>=70&&score[i]<=79) t[2]++;
if
(score[i]>=60&&score[i]<=69) t[3]++;
if
(score[i]>=0 &&score[i]<=59) t[4]++;
if
(score[i]==100) t[5]++;
}
//遍历t数组,输出对应的数据
for
(i=0,m=9;i<6;i++)
{
if
(i==4)
printf
(
"<60\t%d\t%.2f%%\n"
,t[4],(
float
)t[4]/n*100);
if
(i==5)
printf
(
"%d\t%d\t%.2f%%\n"
,100,t[5],(
float
)t[5]/n*100);
if
(i!=4&&i!=5)
{
if
(i==0)
printf
(
"\n"
);
printf
(
"%d-%d\t%d\t%.2f%%\n"
,m*10,m*10+9,t[i],(
float
)t[i]/n*100);
m--;
}
}
}
//直接输出对应列表
void
output(
long
num[],
float
score[],
int
n)
{
int
i;
for
(i=0;i<n;i++)
{
if
(i==0)
printf
(
"\n"
);
printf
(
"%ld\t%.0f\n"
,num[i],score[i]);
}
}
//暂停清屏
void
clean()
{
system
(
"pause"
);
system
(
"cls"
);
}
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.
原文链接:https://blog.csdn.net/kcyxws/article/details/105151639 。
最后此篇关于C语言实现简易学生成绩管理系统的文章就讲到这里了,如果你想了解更多关于C语言实现简易学生成绩管理系统的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我们正在开发一个项目,该项目本身就是 CMS 系统,需要处理大量数字数据,如图像、视频和其他 Assets 。我们正在分析使用用 Java 构建的任何第三方 DAMS 系统的选项,因为我们在同一平台上
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
一个简单的问题。 在 magento 中,当转到 System/Configuration 时,左侧导航中有一些主要选项卡。 一般、目录、客户、销售、高级等。 我想知道什么 xml 为那些设置了顺序?
在开发过程中我发现系统配置->设计 HTML Head 部分丢失。 我已经阅读了很多教程,但没有得到这个问题的解决方案。 我已清除缓存并执行索引。 禁用所有安装模块。 我使用的是magento 1.7
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 5 年前。 Improve this qu
上下文 我正在遵循 GCP 对 Storing Secrets 的说明在存储桶中。 KMS 用于 file encryption在上传到存储桶之前。 由于数据加密发生在 Google 存储之外,我对
我目前正在为 KMS( key 管理服务)编写云形成模板(CFT),我想向 root 以外的用户授予 key 管理权限和 key 使用权限。我希望通过 CFT 动态调用它。到目前为止,我可以授予 ro
我是一名优秀的程序员,十分优秀!