学生成绩管理 c语言源代码

[复制链接]
查看11 | 回复0 | 2007-7-16 00:09:05 | 显示全部楼层 |阅读模式
#include #include#include#include #include#define MAX 80void input();void sort();void display();void insert();void del();void average();void find();void save();void read();void del_file();void average();void modify();int now_no=0;struct student{ int no; char name[20]; char sex[4]; float score1; float score2; float score3; float sort; float ave; float sum;};struct student stu[MAX],*p;main()/*主函数*/{ int as; start: printf("\n\t\t\t欢迎使用学生成绩管理系统\n"); /*一下为功能选择模块*/ do {printf("\n\t\t\t\t1.录入学员信息\n\t\t\t\t2.显示学员信息\n\t\t\t\t3.成绩排序信息\n\t\t\t\t4.添加学员信息\n\t\t\t\t5.删除学员信息\n\t\t\t\t6.修改学员信息\n\t\t\t\t7.查询学员信息\n\t\t\t\t8.从文件读入学员信息\n\t\t\t\t9.删除文件中学员信息\n\t\t\t\t10.保存学员信息\n\t\t\t\t11.退出\n");printf("\t\t\t\t选择功能选项:");fflush(stdin);scanf("%d",&as);switch(as){ case 1:system("cls");input();break; case 2:system("cls");display();break; case 3:system("cls");sort();break; case 4:system("cls");insert();break; case 5:system("cls");del();break; case 6:system("cls");modify();break; case 7:system("cls");find();break; case 8:system("cls");read();break; case 9:system("cls");del_file();break; case 10:system("cls");save();break; case 11:system("exit");exit(0); default:system("cls");goto start;} }while(1); /*至此功能选择结束*/}void input()/*原始数据录入模块*/{ int i=0; char ch; do {printf("\t\t\t\t1.录入学员信息\n输入第%d个学员的信息\n",i+1);printf("\n输入学生编号:");scanf("%d",&stu.no);fflush(stdin);printf("\n输入学员姓名:");fflush(stdin);gets(stu.name);printf("\n输入学员性别:");fflush(stdin);gets(stu.sex);printf("\n输入学员成绩1:");fflush(stdin);scanf("%f",&stu.score1);printf("\n输入学员成绩2:");fflush(stdin);scanf("%f",&stu.score2);printf("\n输入学员成绩3:");fflush(stdin);scanf("%f",&stu.score3);printf("\n\n");i++;now_no=i;printf("是否继续输入?(Y/N)");fflush(stdin);ch=getch();system("cls"); } while(ch!='n'&&ch!='N'); system("cls");}void sort()/*排序数据函数*/{ struct student temp; int i,j; average(); for(i=1;inumstus) { printf("没有查找所要的信息。\n"); return -1;}return i; }}#include"head.h"int openfile(student stu[]){ int i=0,j;
FILE *fp; char filename[20],str[2]; if(numstus!=0) {printf("已经有记录存在,是否保存?(y/n)");gets(str);if(str[0]=='y'||str[0]=='Y') writetotext(stu); } printf("请输入文件名:"); gets(filename); numstus=0; if((fp=fopen(filename,"rb+"))==NULL) {printf("无法打开该文件\n");return(-1); } fscanf(fp,"%d",&numstus); fgetc(fp); while(i0)
{
temp=*(p+j);
*(p+j)=*(p+j+1);
*(p+j+1)=temp;
} } }void sortnum2(student stud[]) {int i,j;student temp;student *p;p=stud;for(i=0;i0)
{
temp=*(p+j);
*(p+j)=*(p+j+1);
*(p+j+1)=temp;
} } } void sortname(student stud[]) {int i,j;student temp;student *p;p=stud;for(i=0;i0)
{
temp=*(p+j);
*(p+j)=*(p+j+1);
*(p+j+1)=temp;
} } } void sortname2(student stud[]) {int i,j;student temp;student *p;p=stud;for(i=0;i0)
{
temp=*(p+j);
*(p+j)=*(p+j+1);
*(p+j+1)=temp;
} } }
void sortcount(student stud[]) {int i,j;student temp;student *p;p=stud;for(i=0;istud[j].index)
{
temp=*(p+j);
*(p+j)=*(p+j+1);
*(p+j+1)=temp;
} } }
void sortcount2(student stud[]) {int i,j;student temp;student *p;p=stud;for(i=0;istud[j+1].index)
{
temp=*(p+j);
*(p+j)=*(p+j+1);
*(p+j+1)=temp;
} } }#include"head.h"void statistic(student stud[])
/*新增功能,输出统计信息*/{
int i,j=0,k=0;
char c1,str[2];
float average[numsubs],sum=0;
if(numstus==0)
printf("没有可被查找的记录\n");
else
{
while(1)
{
printf("下面将统计考试成绩\n");
printf("请选择你要统计哪科的成绩1.A\t2.B\t3.C\t4.D\t5.E\n");
c1=getchar();
printf("\t一共有个%d记录\n",numstus);
/*总共记录数*/
switch(c1)
{
case '1':
for(i=0;istud.subject[0]) k=i;
if(stud[j].subject[0]stud.subject[1]) k=i;
if(stud[j].subject[1]stud.subject[2]) k=i;
if(stud[j].subject[2]stud.subject[3]) k=i;
if(stud[j].subject[3]stud.subject[4]) k=i;
if(stud[j].subject[4]=0){
printf("要删除这个学生的信息吗?(y/n)");
gets(str); if(str[0]=='y'||str[0]=='Y') {
deleterecord(stud,i);
count(stud); } else
{
printf("确定要修改这个学生的信息吗?(y/n)");
gets(str);
if(str[0]=='y'||str[0]=='Y')
{
printf("下面请重新输入学生的信息:\n");
printf("请输入学号:");
gets(stud.number);
printf("请输入姓名:");
gets(stud.name);
printf("请输入性别(男/女1/0):");
gets(str);
if(str[0]=='0')
strcpy(stud.sex,"女");
else
strcpy(stud.sex,"男");
stud.score=0;
printf("请按顺序输入成绩:");
for(j=0;j=0) {for(j=i;jstud.score)
stud.index++; }}#include "head.h"void addrecord(student stud[]){ int i=0,j,num; char str[5]; if(numstus!=0) {printf("已有记录存在是否覆盖?(y/n)\n");gets(str);if(str[0]=='Y'||str[0]=='y') i=0;else i=numstus; } printf("请输入增加的学生信息条目数:");scanf("%d",&num);if(i==0) numstus=num;else numstus+=num;if(numstus>lens){ lens+=50; pointer=(student *)realloc(pointer,lens*LEN);}printf("请输入学生信息:\n");for(;i0) {i=menu_select();
/*控制菜单*/switch(i){case 1:addrecord(pointer);break;
/*增加学生信息*/case 2:findrecord(pointer);break;
/*查询学生信息*/case 3:amendrecord(pointer);break;
/*修改学生信息*/case 4:sort(pointer);break;
/*学生信息排序*/case 5:statistic(pointer);break;
/*统计信息*/case 6:openfile(pointer);break;
/*打开文件*/case 7:writetotext(pointer);break;
/*保存文件*/
case 8:display(pointer,0,numstus-1);break;
/*显示记录*/case 0: if(numstus!=0) printf("是否保存当前记录?(y/n)"); gets(str); if(str[0]=='y'||str[0]=='Y') writetotext(pointer); i=-1;break;
/*退出系统*/default:printf("请输入数字0~8:\n");i=1;
/*输入错误*/} } printf("\t\t欢迎再次使用本系统。\n\n"); display1();}自己一改就能用,给我加分哈!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行