本文目录一览:
C语言编制学生课程信息管理程序
#include stdio.h
#include string.h
int n;
struct Student {
int no;
char name[10];
int score[5];
int sum;
int average;
}student[100000];
void Sort(Student *s){
for(int i=0;in;i++)
for(int j=i+1;jn;j++){
if(s[j].sums[i].sum){
char ns[100];
strcpy(ns,s[i].name);
strcpy(s[i].name,s[j].name);
strcpy(s[j].name,ns);
int snum=s[i].sum,save=s[i].average;
s[i].sum=s[j].sum,s[i].average=s[j].average;
s[j].sum=snum,s[j].average=save;
}
}
}
void printInfo() {
for (int i = 0; i n; i++) {
printf("%s,%d,%d\n", student[i].name, student[i].sum, student[i].average);
}
}
int main()
{
printf("请输入学生的数量n:");
scanf("%d",n);
for (int i = 0; i n; i++) {
printf("请分别输入第%d名同学的id,名字,成绩1,成绩2,成绩3,成绩4", i + 1);
scanf("%d%s%d%d%d%d", student[i].no, student[i].name, student[i].score[0], student[i].score[1], student[i].score[2],student[i].score[3]);
student[i].sum=student[i].score[0]+student[i].score[1]+student[i].score[2]+student[i].score[3];
student[i].average=student[i].sum/4;
}
Sort(student);
printInfo();
return 0;
}
c语言课程设计(学生成绩管理)
#includeiostream.h
/*head.h*/
#includestring.h
#includefstream.h
#includestdlib.h
#includectype.h
typedef struct student
{
char num[6]; //定义学号
char name[8];//定义姓名
// int tax;//定义学生的按总分排名的名次,这个我不做了,自己可以加上,看看怎样修改,都做出来就没意思了呵呵。
int english;//定义英语成绩
int math;//定义数学成绩
// int score;//定义总分 这个我不要了
struct student *next;//指向下一个学生的指针链域
}student;
int getint(int a) //字符转换成数字
{
return (int)(a-'0');
}
student * head1;//头指针,全局变量
void student_read() //从文件中读入学生成绩原始数据
{
int i=7;//共有7个学生的记录,需要时可以修改该初始值
ifstream infile ("student.txt",ios::in);//读文件的操作使用C++
while(i0)
{
student * p;//定义临时结构体指针变量p
p=new student;//开辟内存空间,并将p指向该地址的引用
infilep-nump-namep-englishp-math;//为了简化
p-next=head1-next;
head1-next=p;
i--;//下标减1
}
}
void Reverselist(student *p)
{ student *p1,*p2,*p3;
student *_data;
_data=new student;
p1=p-next;
if(!p1-next) return;
p2=p1-next;
if(!p2-next)
{
strcpy(_data-num,p1-num);
strcpy(_data-name,p1-name);
// _data-tax=p1-tax;
_data-english=p1-english;
_data-math=p1-math;
//_data-score=p1-score;
strcpy(p1-num,p2-num);
strcpy(p1-name,p2-name);
// p1-tax=p2-tax;
p1-english=p2-english;
p1-math=p2-math;
//p1-score=p2-score;
strcpy(p2-num,_data-num);
strcpy(p2-name,_data-name);
// p2-tax=_data-tax;
p2-english=_data-english;
p2-math=_data-math;
//p2-score=_data-score;
return;
}//if
p3=p2-next;
p1-next=NULL;
while(p3-next)
{p2-next=p1;
p1=p2;
p2=p3;
p3=p3-next;
}//while
p2-next=p1;
p3-next=p2;
p-next=p3;
}//Reverselist
void student_order(student *p)
{ student *_temp = p-next;
student *_node = p-next;
student *temp;
temp=new student;
temp-next=NULL;
for (;_temp-next;_temp = _temp-next)
{
for (_node = p-next;_node-next;_node = _node -next)
{
if ((_node-english+_node-math)(_node-next-english+_node-next-math))
{
strcpy(temp-num,_node-num);
strcpy(temp-name,_node-name);
temp-english=_node-english;
temp-math=_node-math;
// temp-score=_node-score;
strcpy(_node-num,_node-next-num);
strcpy(_node-name,_node-next-name);
_node-english=_node-next-english;
_node-math=_node-next-math;
//_node-score=_node-next-score;
strcpy(_node-next-num,temp-num);
strcpy(_node-next-name,temp-name);
_node-next-english=temp-english;
_node-next-math=temp-math;
//_node-next-score=temp-score;
}//if
}//for
}//for
Reverselist(p);
}//student_order
void student_output(student *p)
{ cout"学号 姓名 英语 数学\t\n";
p=p-next;
while(p)
{cout" "p-num"\t"p-name"\t"p-english"\t"p-mathendl;
p=p-next;
}
}
void student_output1(student *p)
{ cout"学号 姓名 英语 数学 总分\t\n";
p=p-next;
while(p)
{ cout" "p-num"\t"p-name"\t"p-english"\t"p-math"\t "(p-english+p-math)endl;
p=p-next;
}
}
void student_write() //将项目数据写入文本文档
{
student * p;
p=head1;
p=p-next;
ofstream outfile("result.txt",ios::out);
while (p!=NULL)
{
outfile" "p-num"\t"p-name"\t"p-english"\t"p-math"\t "p-english+p-mathendl;
p=p-next;
}
outfile.close();
}
/*主程序*/
#includeiostream.h
#includefstream.h
#include stdlib.h
#include stdio.h
#includeconio.h
#include"head.h"
void main()
{ system("color 1b");
head1=new student;
head1-next=NULL;
student_read(); //读入学生数据
student * p1;
p1=head1;
p1=p1-next;
int temp;
student_output(head1); /*显示原有的记录*/
student_order(head1);
student_output1(head1); //信息的输出函数
student_write();//将学校数据写入文本
getch();
}
c语言课程设计学生成绩管理系统
#includestdio.h
#includeconio.h
#include stdlib.h
#includestring.h
#define MAX 80
#define max 3
int nu=0;
struct classname
{
char name[20];
float score;
};
struct student
{
char no[20];
char std_name[20];
struct classname km[max];
float ave;
float sum;
int save;
};
struct student stu[MAX],*p;
void chushi()
{
int i,j;
for(i=0;iMAX;i++)
{
for(j=0;j20;j++)
{
stu[i].no[j]=NULL;
stu[i].std_name[j]=NULL;
stu[i].km[j].name[j]=NULL;
stu[i].km[j].score=0;
}
stu[i].ave=0;
stu[i].sum=0;
stu[i].save=0;
}
}
void av()/*求平均值*/
{
int i;
for(i=0;inu;i++)
{
stu[i].sum=stu[i].km[1].score+stu[i].km[2].score+stu[i].km[3].score;
stu[i].ave=stu[i].sum/3;
}
}
void first_check()
{
FILE *p;
int i,j;
struct classname frist[max];
for(i=0;imax;i++)
{
for(j=0;j20;j++)
frist[i].name[j]=NULL;
frist[i].score=0;
}
if ((p=fopen("c:\\kemu.txt","r"))==NULL)
{
printf("您好,欢迎使用学生成绩管理系统\n\n因为您是第一次使用,请输入科目名称(三科)\n\n");
p=fopen("c:\\kemu.txt","w");
printf("输入课程1名称:");
scanf("%s",frist[0].name);
fprintf(p,"%s\n",frist[0].name);
printf("输入课程2名称:");
scanf("%s",frist[1].name);
fprintf(p,"%s\n",frist[1].name);
printf("输入课程3名称:");
scanf("%s",frist[2].name);
fprintf(p,"%s\n",frist[2].name);
}
system("cls");
fclose(p);
}
void save_nu()
{
FILE *p;
p=fopen("c:\\renshu.txt","w");
fprintf(p,"%d\n",nu);
fclose(p);
}
void Save_add(int n)
{
FILE * p;
int i;
p= fopen("c:\\cheji.txt","at");
if (p == NULL)
{
printf("文件不存在!!\n");
exit(0);
}
save_nu();
for (i = 0;in;i++)
if(stu[i].save==1)
{
stu[i].sum=stu[i].km[1].score+stu[i].km[2].score+stu[i].km[3].score;
stu[i].ave=stu[i].sum/3;
fprintf(p,"%s %s %2.1f %2.1f %2.1f %2.1f %2.1f \n",stu[i].no,stu[i].std_name,stu[i].km[0].score,stu[i].km[1].score,stu[i].km[2].score,stu[i].ave,stu[i].sum);
}
fclose(p);
}
void Save()
{
FILE * p;
int i;
p= fopen("c:\\cheji.txt","w");
if (p == NULL)
{
printf("文件不存在!!\n");
exit(0);
}
save_nu();
for (i = 0;inu;i++)
if(stu[i].save==1)
{
av();
fprintf(p,"%s %s %2.1f %2.1f %2.1f %2.1f %2.1f \n",stu[i].no,stu[i].std_name,stu[i].km[0].score,stu[i].km[1].score,stu[i].km[2].score,stu[i].ave,stu[i].sum);
}
fclose(p);
}
int read_nu()
{
FILE *p;
char ch,s[10]={'\0'};
int i=0;
p=fopen("c:\\renshu.txt","r");
if(p==NULL)
{
save_nu();
return 0;
}
ch=fgetc(p);
while(ch!='\n')
{
s[i]=ch;
ch=fgetc(p);
i++;
}
nu=atoi(s);
fclose(p);
return 0;
}
int read_km()
{
FILE *p;
int i,j=0;
char s[20]={'\0'};
chushi();
p=fopen("c:\\kemu.txt","r");
if(p==NULL)
{
printf("ERROR read_km");
return 0;
}
fgets(s,20,p);
while(strlen(s)!=0)
{
for(i=0;istrlen(s);i++)
if(s[i]==10)
{
s[i]='\0';
break;
}
for(i=0;i=nu;i++)
strcpy(stu[i].km[j].name,s);
for(i=0;i20;i++)
s[i]='\0';
j++;
fgets(s,20,p);
}
}
void read()
{
FILE *p;
int i,j,n,k,z=0;
char s[50]={'\0'};
char o[10]={'\0'};
p=fopen("c:\\cheji.txt","r");
if(p==NULL)
printf("ERROR_read");
chushi();
read_km();
fgets(s,50,p);
while(strlen(s)!=0)
{
j=0;
for(i=0;i50;i++)
{
if(s[i]!='\n')
{
n=0;
while(j==0)
{
if(s[i]!=' ')
{
stu[z].no[n]=s[i];
n++;i++;
}
else
break;
}
while(j==1)
{
if(s[i]!=' ')
{
stu[z].std_name[n]=s[i];
n++;i++;
}
else
break;
}
while(j==2)
{
if(s[i]!=' ')
{
o[n]=s[i];
n++;i++;
}
else
{
stu[z].km[0].score=atoi(o);
break;
}
}
while(j==3)
{
if(s[i]!=' ')
{
o[n]=s[i];
n++;i++;
}
else
{
stu[z].km[1].score=atoi(o);
break;
}
}
while(j==4)
{
if(s[i]!=' ')
{
o[n]=s[i];
n++;i++;
}
else
{
stu[z].km[2].score=atoi(o);
break;
}
}
while(j==5)
{
if(s[i]!=' ')
{
o[n]=s[i];
n++;i++;
}
else
{
stu[z].ave=atoi(o);
break;
}
}
while(j==6)
{
if(s[i]!=' ')
{
o[n]=s[i];
n++;i++;
}
else
{
stu[z].sum=atoi(o);
break;
}
}
for(k=0;k10;k++)
o[k]='\0';
}
else
break;
j++;
}
for(i=0;i50;i++)
s[i]='\0';
fgets(s,50,p);
z++;
}
}
void putin()
{
int n,i=0;
char ch;
read_km();
do
{
printf("\t\t\t\t录入学员信息\n输入第%d个学员的信息\n",i+1);
printf("\n输入学生编号:");
scanf("%s",stu[i].no);
printf("\n输入学员姓名:");
scanf("%s",stu[i].std_name);
printf("\n输入课程%s的分数:",stu[0].km[0].name);
scanf("%f",stu[i].km[0].score);
printf("\n输入课程%s的分数:",stu[0].km[1].name);
scanf("%f",stu[i].km[1].score);
printf("\n输入课程%s的分数:",stu[0].km[2].name);
scanf("%f",stu[i].km[2].score);
stu[i].save=1;
printf("\n\n");
i++;
n=i;
printf("是否继续输入?(Y/N)");
fflush(stdin);
ch=getch();
system("cls");
}
while(ch!='n'ch!='N');
system("cls");
if(nu==0)
{
nu=n;
Save();
}
else
{
nu=n+nu;
Save_add(n);
}
}
int putout()
{
int i;char s;
if(nu==0)
{
printf("学生信息为零!请录入...");
return 0;
}
read();
do
{
printf("学生成绩信息:\n\n");
for(i=0;inu;i++)
printf("学号:%s 姓名:%s\n%s分数:%2.1f\t%s分数:%2.1f\t%s分数:%2.1f\n平均分数:%2.1f\t总成绩:%2.1f\n\n",stu[i].no,stu[i].std_name,stu[i].km[0].name,stu[i].km[0].score,stu[i].km[1].name,stu[i].km[1].score,stu[i].km[2].name,stu[i].km[2].score,stu[i].ave,stu[i].sum);
printf("\t\t按任意键返回主菜单");
fflush(stdin);
s=getch();
}
while(!s);
system("cls");
}
int sort()/*排序数据函数*/
{
struct student temp;
int i,j;
char s;
if(nu==0)
{
printf("学生信息为零!请录入...");
return 0;
}
chushi();
read();
for(i=1;inu;i++)
{
for(j=1;j=nu-i;j++)
{
if(stu[j-1].avestu[j].ave)
{
temp=stu[j];
stu[j]=stu[j-1];
stu[j-1]=temp;
}
}
}
do
{
printf("学生成绩信息:\n\n");
for(i=0;inu;i++)
printf("学号:%s 姓名:%s 平均成绩:%2.1f\n\n",stu[i].no,stu[i].std_name,stu[i].ave);
printf("\t\t按任意键返回主菜单");
fflush(stdin);
s=getch();
}
while(!s);
system("cls");
}
void find()/*查询函数*/
{
int j,i=0;
int c=0;
char search[10]={'\0'};
char as;
if(nu==0)
{
printf("学生信息为零!请录入...");
return 0;
}
chushi();
read();
do
{
printf("输入要查询课程名称:");
scanf("%s",search);
for(j=0;jmax;j++)
if(!strcmp(stu[i].km[j].name,search))
{
c=1;
printf("\n该课程不及格学生姓名:\n");
for(i=0;inu;i++)
if(stu[i].km[j].score60)
printf("%s\n",stu[i].std_name);
}
if(c==0)
printf("无此课程!");
printf("\n\t\t按任意键返回主菜单");
fflush(stdin);
as=getch();
}
while(!as);
system("cls");
}
void tongji()
{
int j,m,z,i=0;
char s;
if(nu==0)
{
printf("学生信息为零!请录入...");
return 0;
}
chushi();
read();
for(z=0;zmax;z++)
{
m=stu[i].km[z].score;j=0;
printf("%s 最高分: ",stu[i].km[z].name);
for(i=0;inu;i++)
if(mstu[i].km[z].score)
{
m=stu[i].km[z].score;
j=i;
}
printf("%s\t",stu[j].std_name);
j=0;i=0;m=stu[i].km[z].score;
printf("%s 最低分: ",stu[i].km[z].name);
for(i=0;inu;i++)
if(mstu[i].km[z].score)
{
m=stu[i].km[z].score;
j=i;
}
printf("%s\t",stu[j].std_name);
m=0;j=0;i=0;
printf("%s 平均分: ",stu[i].km[z].name);
for(i=0;inu;i++)
m=m+stu[i].km[z].score;
printf("%d\n",m/nu);
m=0;i=0;
printf("%s 分数低于的60人数: ",stu[i].km[z].name);
for(i=0;inu;i++)
if(stu[i].km[z].score60)
m++;
printf("%d\t",m);
m=0;j=0;i=0;
printf("%s 分数高于60的人数: ",stu[i].km[z].name);
for(i=0;inu;i++)
if(stu[i].km[z].score60)
m++;
printf("%d\n\n",m);
}
do
{
printf("\t\t按任意键返回主菜单");
fflush(stdin);
s=getch();
}
while(!s);
system("cls");
}
void main()/*主函数*/
{
int as;
first_check();
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");
printf("\t\t\t\t选择功能选项:");
fflush(stdin);
read_nu();
scanf("%d",as);
switch(as)
{
case 1:system("cls");putin();break;
case 2:system("cls");putout();break;
case 3:system("cls");sort();break;
case 4:system("cls");find();break;
case 5:system("cls");tongji();break;
case 6:system("exit");exit(0);
default:system("cls");goto start;
}
}
while(1);
/*至此功能选择结束*/
}
C语言课程设计任务——学生成绩统计程序设计
#includestdio.h /*引用库函数*/
#includestdlib.h
#includectype.h
#includestring.h
typedef struct /*定义结构体数组*/
{
char num[10]; /*学号*/
char name[20]; /*姓名*/
int score; /*成绩*/
}Student;
Student stu[80]; /*结构体数组变量*/
int menu_select() /*菜单函数*/
{
char c;
do{
system("cls"); /*运行前清屏*/
printf("\t\t****Students' Grade Management System****\n"); /*菜单选择*/
printf("\t\t | 1. Input Records |\n");
printf("\t\t | 2. Display All Records |\n");
printf("\t\t | 3. Sort |\n");
printf("\t\t | 4. Insert a Record |\n");
printf("\t\t | 5. Delete a Record |\n");
printf("\t\t | 6. Query |\n");
printf("\t\t | 7. Statistic |\n");
printf("\t\t | 8. Add Records from a Text File|\n");
printf("\t\t | 9. Write to a Text file |\n");
printf("\t\t | 0. Quit |\n");
printf("\t\t*****************************************\n");
printf("\t\t\tGive your Choice(0-9):");
c=getchar(); /*读入选择*/
}while(c'0'||c'9');
return(c-'0'); /*返回选择*/
}
int Input(Student stud[],int n) /*输入若干条记录*/
{int i=0;
char sign,x[10]; /*x[10]为清除多余的数据所用*/
while(sign!='n'sign!='N') /*判断*/
{ printf("\t\t\tstudent's num:"); /*交互输入*/
scanf("\t\t\t%s",stud[n+i].num);
printf("\t\t\tstudent's name:");
scanf("\t\t\t%s",stud[n+i].name);
printf("\t\t\tstudent's score:");
scanf("\t\t\t%d",stud[n+i].score);
gets(x); /*清除多余的输入*/
printf("\t\t\tany more records?(Y/N)");
scanf("\t\t\t%c",sign); /*输入判断*/
i++;
}
return(n+i);
}
void Display(Student stud[],int n) /*显示所有记录*/
{
int i;
printf("\t\t\t-----------------------------------\n"); /*格式头*/
printf("\t\t\tnumber name score\n");
printf("\t\t\t-----------------------------------\n");
for(i=1;in+1;i++) /*循环输入*/
{
printf("\t\t\t%-16s%-15s%d\n",stud[i-1].num,stud[i-1].name,stud[i-1].score);
if(i1i%10==0) /*每十个暂停*/
{printf("\t\t\t-----------------------------------\n"); /*格式*/
printf("\t\t\t");
system("pause");
printf("\t\t\t-----------------------------------\n");
}
}
printf("\t\t\t");
system("pause");
}
void Sort_by_num(Student stud[],int n) /*按学号排序*/
{ int i,j,*p,*q,s;
char t[10];
for(i=0;in-1;i++) /*冒泡法排序*/
for(j=0;jn-1-i;j++)
if(strcmp(stud[j].num,stud[j+1].num)0)
{strcpy(t,stud[j+1].num);
strcpy(stud[j+1].num,stud[j].num);
strcpy(stud[j].num,t);
strcpy(t,stud[j+1].name);
strcpy(stud[j+1].name,stud[j].name);
strcpy(stud[j].name,t);
p=stud[j+1].score;
q=stud[j].score;
s=*p;
*p=*q;
*q=s;
}
}
int Insert_a_record(Student stud[],int n) /*插入一条记录*/
{char x[10]; /*清除多余输入所用*/
printf("\t\t\tstudent's num:"); /*交互式输入*/
scanf("\t\t\t%s",stud[n].num);
printf("\t\t\tstudent's name:");
scanf("\t\t\t%s",stud[n].name);
printf("\t\t\tstudent's score:");
scanf("\t\t\t%d",stud[n].score);
gets(x);
n++;
Sort_by_num(stud,n); /*调用排序函数*/
printf("\t\t\tInsert Successed!\n"); /*返回成功信息*/
return(n);
}
int Delete_a_record(Student stud[],int n) /*按姓名查找,删除一条记录*/
{ char s[20];
int i=0,j;
printf("\t\t\ttell me his(her) name:"); /*交互式问寻*/
scanf("%s",s);
while(strcmp(stud[i].name,s)!=0in) i++; /*查找判断*/
if(i==n)
{ printf("\t\t\tnot find!\n"); /*返回失败信息*/
return(n);
}
for(j=i;jn-1;j++) /*删除操作*/
{
strcpy(stud[j].num,stud[j+1].num);
strcpy(stud[j].name,stud[j+1].name);
stud[j].score=stud[j+1].score;
}
printf("\t\t\tDelete Successed!\n"); /*返回成功信息*/
return(n-1);
}
void Query_a_record(Student stud[],int n) /*查找并显示一个记录*/
{ char s[20];
int i=0;
printf("\t\t\tinput his(her) name:"); /*交互式输入*/
scanf("\t\t\t%s",s);
while(strcmp(stud[i].name,s)!=0in) i++; /*查找判断*/
if(i==n)
{ printf("\t\t\tnot find!\n"); /*输入失败信息*/
return;
}
printf("\t\t\this(her) number:%s\n",stud[i].num); /*输出该学生信息*/
printf("\t\t\this(her) score:%d\n",stud[i].score);
}
void Statistic(Student stud[],int n) /*新增功能,输出统计信息*/
{ int i,j=0,k=0,sum=0;
float aver; /*成绩平均值*/
for(i=0;in;i++) /*循环输入判断*/
{
sum+=stud[i].score;
if(stud[j].scorestud[i].score) j=i;
if(stud[k].scorestud[i].score) k=i;
}
aver=1.0*sum/n;
printf("\t\t\tthere are %d records.\n",n); /*总共记录数*/
printf("\t\t\tthe hignest score:\n"); /*最高分*/
printf("\t\t\tnumber:%s name:%s score:%d\n",stud[j].num,stud[j].name,stud[j].score);
printf("\t\t\tthe lowest score:\n"); /*最低分*/
printf("\t\t\tnumber:%s name:%s score:%d\n",stud[k].num,stud[k].name,stud[k].score);
printf("\t\t\tthe average score is %5.2f\n",aver); /*平均分*/
}
int AddfromText(Student stud[],int n) /*从文件中读入数据*/
{ int i=0,num;
FILE *fp; /*定义文件指针*/
char filename[20]; /*定义文件名*/
printf("\t\t\tInput the filename:");
scanf("\t\t\t%s",filename); /*输入文件名*/
if((fp=fopen(filename,"rb"))==NULL) /*打开文件*/
{ printf("\t\t\tcann't open the file\n"); /*打开失败信息*/
printf("\t\t\t");
system("pause");
return(n);
}
fscanf(fp,"%d",num); /*读入总记录量*/
while(inum) /*循环读入数据*/
{
fscanf(fp,"%s%s%d",stud[n+i].num,stud[n+i].name,stud[n+i].score);
i++;
}
n+=num;
fclose(fp); /*关闭文件*/
printf("\t\t\tSuccessed!\n");
printf("\t\t\t");
system("pause");
return(n);
}
void WritetoText(Student stud[],int n) /*将所有记录写入文件*/
{
int i=0;
FILE *fp; /*定义文件指针*/
char filename[20]; /*定义文件名*/
printf("\t\t\tWrite Records to a Text File\n"); /*输入文件名*/
printf("\t\t\tInput the filename:");
scanf("\t\t\t%s",filename);
if((fp=fopen(filename,"w"))==NULL) /*打开文件*/
{
printf("\t\t\tcann't open the file\n");
system("pause");
return;
}
fprintf(fp,"%d\n",n); /*循环写入数据*/
while(in)
{
fprintf(fp,"%-16s%-15s%d\n",stud[i].num,stud[i].name,stud[i].score);
i++;
}
fclose(fp); /*关闭文件*/
printf("Successed!\n"); /*返回成功信息*/
}
void main() /*主函数*/
{
int n=0;
for(;;)
{
switch(menu_select()) /*选择判断*/
{
case 1:
printf("\t\t\tInput Records\n"); /*输入若干条记录*/
n=Input(stu,n);
break;
case 2:
printf("\t\t\tDisplay All Records\n"); /*显示所有记录*/
Display(stu,n);
break;
case 3:
printf("\t\t\tSort\n");
Sort_by_num(stu,n); /*按学号排序*/
printf("\t\t\tSort Suceessed!\n");
printf("\t\t\t");
system("pause");
break;
case 4:
printf("\t\t\tInsert a Record\n");
n=Insert_a_record(stu,n); /*插入一条记录*/
printf("\t\t\t");
system("pause");
break;
case 5:
printf("\t\t\tDelete a Record\n");
n=Delete_a_record(stu,n); /*按姓名查找,删除一条记录*/
printf("\t\t\t");
system("pause");
break;
case 6:
printf("\t\t\tQuery\n");
Query_a_record(stu,n); /*查找并显示一个记录*/
printf("\t\t\t");
system("pause");
break;
case 7:
printf("\t\t\tStatistic\n");
Statistic(stu,n); /*新增功能,输出统计信息*/
printf("\t\t\t");
system("pause");
break;
case 8:
printf("\t\t\tAdd Records from a Text File\n");
n=AddfromText(stu,n); /*新增功能,输出统计信息*/
break;
case 9:
printf("\t\t\tWrite to a Text file\n");
WritetoText(stu,n); /*循环写入数据*/
printf("\t\t\t");
system("pause");
break;
case 0:
printf("\t\t\tHave a Good Luck,Bye-bye!\n"); /*结束程序*/
printf("\t\t\t");
system("pause");
exit(0);
}
}
}
这个我想就是你要的程序,具体功能跟你说的差不多