求一个学生成绩管理系统的C语言代码!!急!!

功能需求1、学籍号2、学生姓名3、性别4、各科成绩{高数、线数、导论、思修、c语言、英语、体育}5、计算总分、平均分6、考试次数这是期末作业,如果有类似而需要改的请改好再... 功能需求
1、学籍号
2、学生姓名
3、性别
4、各科成绩{高数、线数、导论、思修、c语言、英语、体育}
5、计算总分、平均分
6、考试次数
这是期末作业,如果有类似而需要改的请改好再发,谢谢大家
展开
 我来答
undergrowth
2009-12-17 · TA获得超过1513个赞
知道小有建树答主
回答量:879
采纳率:0%
帮助的人:1204万
展开全部
#include<stdio.h>
#include<string.h>卜宏
#include<stdlib.h>
#include<conio.h>

struct student
{ char num[10];
char name[20];
char sex[5];
float grade[7];
float v;
float sum;
}stu[50];
int k=0;

void input();
void output();
void search();
void average();
void sort();
void save();

void main()
{
int a;
do
{

printf("\n\n ******************************************************************\n");
printf(" *"); printf("\t\twelcome enter the student management system"); printf("\t*");
printf("\n ******************************************************************\n");

printf(" *"); printf("\t 1.Access student information"); printf("\t\t\t\t*\n");
printf(" *"); printf("\t 2.Output student information"); printf("\含弊此t\t\t\t*\n");
printf(" *"); printf("\t 3.Search student information"); printf("\t\t\t\t*\n");
printf(" *"); printf("\t 4.By sum Sort student information and output"); printf("\t\t*\n");
printf(" *"); printf("\t 5.save the student information"); printf("\t\t\t*\n");
printf(" *"); printf("\t 6. exit "); printf("\t\t\t\t\t*\n");
printf(" ******************************************************************\n");

printf(" Enter you choice : ");
scanf("%d",&a);

switch(a)
{

case 1:printf("\谈迅n");input();break;
case 2:printf("\n");output();break;
case 3:printf("\n");search();break;
case 4:printf("\n");sort();break;
case 5:printf("\n");save();break;
case 6:printf("\n");exit(0);break;
default:printf("\nThe choice is between 1 to 6.\n");
}
}while(a!=0);

}

void input()
{ int j;
char ch[20];
printf("\nenter student information:\n");
do
{ printf("\nnum: ");
scanf("%s",stu[k].num);
printf("\nname: ");
scanf("%s",stu[k].name);
printf("\nsex: ");
scanf("%s",stu[k].sex);
for(j=0;j<7;j++)
{ printf("\ngrade%d: ",j+1);
scanf("%f",&stu[k].grade[j]); }
k++;
printf("\nif want continue input student information(y/n): ");
scanf("%s",ch);
}while(strcmp(ch,"y")==0||strcmp(ch,"Y")==0);
average();
output();
}

void output()
{ int i;
printf(" the student information is:\n");
for(i=0;i<k;i++)
{ printf("%-10s %-10s %-5s %.2f %.2f %.2f %.2f %.2f %.2f %.2f %8f %8f\n",stu[i].num,stu[i].name,stu[i].sex,stu[i].grade[0],stu[i].grade[1],stu[i].grade[2],stu[i].grade[3],stu[i].grade[4],stu[i].grade[5],stu[i].grade[6],stu[i].sum,stu[i].v);
printf("\n"); }
}

void average()
{ int i,j;
for(i=0;i<k;i++)
{ stu[i].sum=0;
for(j=0;j<7;j++)
stu[i].sum=stu[i].sum+stu[i].grade[j] ;
stu[i].v=stu[i].sum/7; }
}

void search()

{ int i,j;
char a[20],ch[10],c[20];

printf("\nenter you want look student num:");
scanf("%s",a);
for(i=0;i<k;i++)
if(strcmp(stu[i].num,a)==0) printf("%-10s %-10s %-5s %.2f %.2f %.2f %.2f %.2f %.2f %.2f %8f %8f\n",stu[i].num,stu[i].name,stu[i].sex,stu[i].grade[0],stu[i].grade[1],stu[i].grade[2],stu[i].grade[3],stu[i].grade[4],stu[i].grade[5],stu[i].grade[6],stu[i].sum,stu[i].v);

printf("you sure want change student information: ");
scanf("%s",ch);
if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)
{ printf("\nenter you want change student num:");
scanf("%s",a);
for(i=0;i<k;i++)
{
if(strcmp(stu[i].num,a)==0)
{ printf("\nyou sure want change student num(y/n): ");
scanf("%s",ch);
if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nnum:"); scanf("%s",stu[i].num);}
printf("\nyou sure want change student name(y/n): ");
scanf("%s",ch);
if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nname:"); scanf("%s",stu[i].name);}
printf("\nyou sure want change student sex(y/n): ");
scanf("%s",ch);
if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0) { printf("\nsex:"); scanf("%s",stu[i].sex);}
printf("\nyou sure want change student grade(y/n): ");
scanf("%s",ch);
if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)
for(j=0;j<7;j++)
{ printf("grade%d:",j+1); scanf("%f",&stu[i].grade[j]); printf("\n"); }
stu[i].sum=0;
for(j=0;j<7;j++)
stu[i].sum=stu[i].sum+stu[i].grade[j] ;
stu[i].v=stu[i].sum/7;
}
} } printf("\nyou sure want delete student information(y/n): ");
scanf("%s",ch);
if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)
{ printf("\nenter you want delete num :\n");
printf("num:");
scanf("%s",&c);
for(i=0;i<k;i++)
if(strcmp(c,stu[i].num)==0) break;
for(j=i;j<=2;j++)
stu[j]=stu[j+1];
printf("\t\t\tyou had delete %s\n",c);
k--; }

output();
}

void sort()
{ struct student temp;
int i,j;
for(i=0;i<k-1;i++)
{
for(j=i+1;j<k;j++)
{
if(stu[i].sum<stu[j].sum)
{
temp=stu[i];
stu[i]=stu[j];
stu[j]=temp;
}
} }
output();
}

void save()
{ FILE *fp; int i;
if((fp=fopen("xinxi.txt","w"))==NULL)
{ printf("cannot write the file.\n");
exit(0);}
for(i=0;strlen(stu[i].num)!=0;i++)
fprintf(fp,"%-10s %-10s %-5s %.2f %.2f %.2f %.2f %.2f %.2f %.2f %8f %8f\n",stu[i].num,stu[i].name,stu[i].sex,stu[i].grade[0],stu[i].grade[1],stu[i].grade[2],stu[i].grade[3],stu[i].grade[4],stu[i].grade[5],stu[i].grade[6],stu[i].sum,stu[i].v);
fclose(fp);
}

调试通过 有问题hi我
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式