这篇文章主要为大家详细介绍了C语言学生成绩管理系统源码,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了C语言学生成绩管理系统的具体代码,供大家参考,具体内容如下
效果如下:

代码如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student{
int num;
char name[20];
float score1;
float score2;
float score3;
double total;
}stu[4];
void a();
void b();
void c();
void d();
void e();
int main(void)
{
//printf("Hello World!\n");
int n;
while(n!=6){
printf("\t student score manage system\n");
printf("1-input all student's score!\n");
printf("2-show all student's score!\n");
printf("3-output student's average score!\n");
printf("4-output student's score and rank!\n");
printf("5-result output txt file!\n");
printf("6-exit!\n");
scanf("%d",&n);
switch(n){
case 1:a();break;
case 2:b();break;
case 3:c();break;
case 4:d();break;
case 5:e();break;
case 6:printf("******ByeBye******");break;
}
}
return 0;
}
//输入成绩
void a(){
int i;
for(i=0;i<4;i++){
printf("input num name score1 score2 score3: ");
scanf("%d%s%f%f%f",&stu[i].num,stu[i].name,&stu[i].score1,&stu[i].score2,&stu[i].score3);
}
for(i=0;i<4;i++){
stu[i].total=stu[i].score1+stu[i].score2+stu[i].score3;
}
}
//输出成绩
void b(){
int i;
printf("num \t name \t score1 \t score2 \t score3 \t total \n");
for(i=0;i<4;i++){
printf("%d \t %s \t %f \t %f \t %f \t %f \n",stu[i].num,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].total);
}
}
//求平均成绩
void c(){
double total=0;
double avg;
int i;
for(i=0;i<4;i++){
total+=stu[i].total;
}
avg=total/4.0;
printf("avg is :%f \n",avg);
}
//按照总成绩排序
void d(){
struct student temp;
int i,j;
for(i=0;i<4;i++){
for(j=i+1;j<4;j++){
temp=stu[i];
stu[i]=stu[j];
stu[j]=temp;
}
}
printf("num \t name \t score1 \t score2 \t score3 \t total \n");
for(i=0;i<4;i++){
printf("%d \t %s \t %f \t %f \t %f \t %f \n",stu[i].num,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].total);
}
}
// 保存数据到文件
void e(){
int i;
FILE *fp;
fp=fopen("E:/result.txt","w");
fprintf(fp,"num \t name \t score1 \t score2 \t score3 \t total \n");
for(i=0;i<4;i++){
fprintf(fp,"%d \t %s \t %f \t %f \t %f \t %f \n",stu[i].num,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].total);
}
printf(" save success! \n ");
}以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程学习网。
织梦狗教程
本文标题为:C语言学生成绩管理系统源码
基础教程推荐
猜你喜欢
- centos 7 vscode cmake 编译c++工程 2023-09-17
- 全面了解C语言 static 关键字 2023-03-26
- C语言实现宾馆管理系统课程设计 2023-03-13
- C++实战之二进制数据处理与封装 2023-05-29
- C语言编程C++旋转字符操作串示例详解 2022-11-20
- [C语言]二叉搜索树 2023-09-07
- 带你深度走入C语言取整以及4种函数 2022-09-17
- C++实现ETW进行进程变动监控详解 2023-05-15
- C语言 详解字符串基础 2023-03-27
- [c语言-函数]不定量参数 2023-09-08
