#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 101
typedef struct student{
 char number[15];
 char name[30];
 int score;
}STUDENT;
/*******************************************************************************
*                         
以下是函数声明部分                                  *
********************************************************************************/
int intputInfo(STUDENT *stu,int length);
void outputInfo(STUDENT *stu,int length);
void queryInfo(STUDENT *stu,int length,char *stuNum);
int only(STUDENT *stu,int k,char *num);
void login(char *p);
int insert(STUDENT *stu,int length);
int del(STUDENT *stu,int length);
void paixu(STUDENT *stu,int length);
void save(STUDENT *stu,int length);
int open(STUDENT *stu);
void displayMenu();
/******************************************************************************
*                        
以下是主函数部分                                    *
*******************************************************************************/
main()
{
 STUDENT student[N];
 STUDENT *stu;
 int length,choose;
 char password[10],stuNum[15];
 length=0;
 stu=student; 
 login(password);
 while(1)
 {
  displayMenu();
  printf(“请选择(1,2,3,4,5,6,7,8,9): “);
  scanf(“%d”,&choose);
  switch(choose)
  {
  case 1:
   {
    printf(“当输入学号为0时结束输入信息n”);
    length=intputInfo(stu,length);
    printf(“nn”);
    printf(“共有%d个学生信息n”,length);
   }
   break;
  case 2:
   {
    if(length==0)
     printf(“n无学生信息!nn”);
    else
    {
     outputInfo(stu,length);
     printf(“n”);
        printf(“共有%d个学生信息n”,length);
    }
   }break;
  case 3:
   {
    if(length==0)
     printf(“n无学生信息!nn”);
    else
    {
     printf(“请输入要查询学生的学号: “);
         getchar();
        gets(stuNum);
        printf(“n”);
        queryInfo(stu,length,stuNum);
    }
   }break;
  case 4:
   {
    if(length==0)
     printf(“n无学生信息!nn”);
    else
    {
     length=insert(stu,length);
        printf(“nn”);
        printf(“共有%d个学生信息n”,length);
    }
   }break;
  case 5:
   {
    if(length==0)
     printf(“n无学生信息!nn”);
    else
    {
     length=del(stu,length);
     outputInfo(stu,length);
     printf(“n”);
        printf(“共有%d个学生信息n”,length);
    }
   }break;  
  case 6:
   {
    if(length==0)
     printf(“n无学生信息!nn”);
    else
    {
     paixu(stu,length);
     outputInfo(stu,length);
     printf(“n”);
        printf(“共有%d个学生信息n”,length);
    }
   }break;
  case 7:
   {
    if(length==0)
     printf(“n学生信息为空,不能完成存储!nn”);
    else
    {
     save(stu,length);
           printf(“存储完毕!n”);
    }
   }break;
  case 8:
   {
    if(!(stu+1)->number)
     printf(“n无学生信息!nn”);
    else
    {
     printf(“n”);
     length=open(stu);
        printf(“n读取完毕!n”);
    }
   }break;
  case 9:exit(1);
  }
 }
}                                          
/****************************************************************************************************
*                                     
以下是函数的定义部分                                         *
*****************************************************************************************************/
void displayMenu()
{
 printf(“+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++n”);
 printf(“+                         
学生成绩管理系统2.0                                +n”);
 printf(“+       1.输入信息            4.插入信息         
7.保存到文件                +n”);
 printf(“+       2.输出信息            5.按学号删除       
8.从文件读                  +n”);
 printf(“+       3.按学号查            6.按成绩排序       
9.程序结束                  +n”);
 printf(“+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++n”);

大神,我这代码复制好了,能帮我改改吗?
#include
#include
#include
static int stnum;
char hint[80]=”请按提示输入!”;
struct Score
{
double yuwen,math,english,tiyu,sum;
};
struct Student
{
char num[10],name[20],sex[10];
int age;

}
/**********************************
*         登陆密码:               *
***********************************/
void login(char *p)
{
 char a[10]=”123″;
 do
 {
  printf(“输入口令:(输入123)”);
澳门新葡萄京官网注册 ,  gets(p);
 }
 while(strcmp(p,a)!=0);
}
/**************************************
*             输入信息                *
***************************************/
int intputInfo(STUDENT *stu,int length)
{
 int i,flag;
 i=length;
 while(1)
 {
  printf(“学号: “);
  scanf(“%s”,&(stu+i)->number);
  if(strcmp((stu+i)->number,”0″)==0)
   break;
  if(i>0)
  {
   flag=only(stu,i,(stu+i)->number);
   if(flag==1)
   {
    printf(“输入学号重复,请重新输入!n”);
       continue;
   }
  }
  printf(“姓名: “);
  scanf(“%s”,&(stu+i)->name);
  printf(“成绩: “);
  scanf(“%d”,&((stu+i)->score));
  i++;
 }
 return i;
}
/*********************************************
*               输出信息                     *
**********************************************/
void outputInfo(STUDENT *stu,int length)
{
 int i;
 printf(“nn”);
 printf(”   学号             姓名               成绩n”);
 for(i=0;i<length;i++)
  printf(“%-20s%-20s%-20dn”,(stu+i)->number,(stu+i)->name,(stu+i)->score);
 printf(“nn”);
}
/********************************************
*                按学号查                   *
*********************************************/
void queryInfo(STUDENT *stu,int length,char *stuNum)
{
 int i,k;
 k=0;
 for(i=0;i<length;i++)
 {
  if(strcmp((stu+i)->number,stuNum)==0)
  {
   printf(“学号: %sn”,(stu+i)->number);
   printf(“姓名: %sn”,(stu+i)->name);
   printf(“成绩: %dnn”,(stu+i)->score);
  }
  else
   k++;
 }
 if(k==length)
  printf(“无此学生信息!nn”);
}
/**********************************************************
*                 判断学号的唯一性                        *
***********************************************************/
int only(STUDENT *stu,int k,char *num)
{
 int i,n;
 n=0;
 for(i=0;i<k;i++)
 {
  if(strcmp((stu+i)->number,num)==0)
   break;
  else
   n++;
 }
 if(n==k)
  return 0;
 else
  return 1;
}
/*****************************************************
*                  插入信息                          *
******************************************************/
int insert(STUDENT *stu,int length)
{
 int i,flag,j,place;
 char num[15];
 i=length;
 length++;
 printf(“选择要插入的位置: “);
 scanf(“%d”,&place);
 if(place>length-1||place<=0)
 {
  printf(“没有该位置!n”);
  length–;
 }
 else
 {
  printf(“学号: “);
     scanf(“%s”,&num);
     flag=only(stu,i,num);
  if(flag==1)
  {
   printf(“n学号重复!”);
      length–;
  }
  else
  {
   for(j=length-1;j>=place;j–)
   {
    strcpy((stu+j)->number,(stu+j-1)->number);
       strcpy((stu+j)->name,(stu+j-1)->name);
       (stu+j)->score=(stu+j-1)->score;
   }
   strcpy((stu+place-1)->number,num);
      printf(“姓名: “);
         scanf(“%s”,&(stu+place-1)->name);
         printf(“成绩: “);
         scanf(“%d”,&(stu+place-1)->score);
  }
 }
 return length;
}
/****************************************************
*                    按学号删除                     *
*****************************************************/
int del(STUDENT *stu,int length)
{
 char num[15];
 int i,j,k;
 k=0;
 printf(“输入要删除的学号: “);
 scanf(“%s”,&num);
 for(i=0;i<length;i++)
  if(strcmp((stu+i)->number,num)==0)
  { for(j=i;j<length;j++)
   {
   strcpy((stu+j)->number,(stu+j+1)->number);
   strcpy((stu+j)->name,(stu+j+1)->name);
   (stu+j)->score=(stu+j+1)->score;
   }
      k++;
  }
 if(k!=0)
  length–;
 else
  printf(“输入的学号有误!n”);
 return length;
}
/******************************************************
*                  按成绩排序                         *
*              (选择排序法:降序)                     *
*******************************************************/
void paixu(STUDENT *stu,int length)
{
 int i,j,k,temp1;
 char *temp2,*temp3;
 temp2=stu->name;
 temp3=stu->number;
 for(i=0;i<length-1;i++)
 {
  k=i;
  for(j=k+1;j<length;j++)
   if((stu+k)->score<(stu+j)->score)
    k=j;
  temp1=(stu+i)->score;
  temp2=(char *)malloc(sizeof(char));
  temp3=(char *)malloc(sizeof(char));
        (stu+i)->score=(stu+k)->score;
  (stu+k)->score=temp1;
  strcpy(temp2,(stu+i)->name);
     strcpy((stu+i)->name,(stu+k)->name);
     strcpy((stu+k)->name,temp2);
  strcpy(temp3,(stu+i)->number);
  strcpy((stu+i)->number,(stu+k)->number);
  strcpy((stu+k)->number,temp3);
 }
}
/*****************************************************
*                     保存到文件                     *
******************************************************/
void save(STUDENT *stu,int length)
{
 FILE *fp;
 int i;
 fp=fopen(“myfile.txt”,”w”);
 for(i=0;i<length;i++)
  fprintf(fp,”%20s%20s%20dn”,(stu+i)->number,(stu+i)->name,(stu+i)->score);
 fclose(fp);
}
int open(STUDENT *stu)
{
 FILE *fp;
 int i=0;
 fp=fopen(“myfile.txt”,”r”);
 if(fp==NULL)
  printf(“无学生信息!n”);
 else
 {
  printf(”   学号             姓名               成绩n”);
  while(feof(fp)==0)
  {
   fscanf(fp,”%20s%20s%20dn”,(stu+i)->number,(stu+i)->name,&(stu+i)->score);
   printf(“%-20s%-20s%-20dn”,(stu+i)->number,(stu+i)->name,(stu+i)->score);
   i++;
  }
  fclose(fp);
 }
 return i;
}

struct Score score;
}stu[5];
void sethint(const char s)
{
strcpy;
}
void printline()
{
int i;
for(i=0;i<80;i++)
putchar;
}
void printtitle(const char
title)
{
int i;
int length=strlen;
putchar;
for(i=0;i<(80-2-length)/2;i++)
putchar;
printf(“%s”,title);
for(i=i+length-1;i<=80-4;i++)
putchar;
putchar;
}
void menu()
{
printline();
printtitle(“学生成绩管理系统”);
printline();
printtitle(“输入指令,执行相应操作”);
printtitle(“1.学生信息的录入 2.学生信息的查询”);
printtitle(“3.学生信息的删除 4.学生信息的排序”);
printtitle(“5.学生信息的修改 6.学生信息的保存”);
printtitle(“7.学生信息的显示 8.退出系统”);
printline();
printtitle;
printline();
}
void modelmenu(const char *s)
{
printline();
printtitle;
printline();
}
void input()
{
int i=0; char l; system;
modelmenu;
i=stnum;
printf(“已经输入了%d个学生的信息!”,i++);
printf(“n输入第%d个学员学号:”,i);
scanf(“%s”,stu[i].num); getchar();
printf(“n输入第%d个学员姓名:”,i);
scanf(“%s”,stu[i].name); getchar();
printf(“n输入第%d个学员性别:”,i);
scanf(“%s”,stu[i].sex); getchar();
printf(“n输入第%d个学员年龄:”,i);
scanf(“%d”,&stu[i].age); getchar();
printf(“n输入第%d个学员语文成绩:”,i);
scanf(“%lf”,&stu[i].score.yuwen); getchar();
printf(“n输入第%d个学员数学成绩:”,i);
scanf(“%lf”,&stu[i].score.math); getchar();
printf(“n输入第%d个学员英语成绩:”,i);
scanf(“%lf”,&stu[i].score.english); getchar();
printf(“n输入第%d个学员体育成绩:”,i);
scanf(“%lf”,&stu[i].score.tiyu); getchar();
stu[i].score.sum+=stu[i].score.yuwen+stu[i].score.math+
stu[i].score.english+stu[i].score.tiyu;
printf(“%st%st%st%dt%.1ft%.1ft%.1ft%.1ft%.1fn”,
stu[i].num,stu[i].name,stu[i].sex,stu[i].score.yuwen,stu[i].score.math,
stu[i].score.english,stu[i].score.tiyu,stu[i].score.sum);
stnum++;
printf(“是否继续输入?;
scanf(“%c”,&l);
if(l==’n’||l==’N’)
return;
else if(l==’Y’||l==’y’)
{
system;
input();
}
}
void search()
{
int i=0,flag=1;
char str[20],l; system;
modelmenu;
printf(“请输入要查找的学员学号:”);
scanf; getchar();
for(i=0;i if((strcmp(str,stu[i].num))==0)
{
printf(“%st%st%st%dt%.1ft%.1ft%.1ft%.1ft%.1fn”,
stu[i].num,stu[i].name,stu[i].sex,stu[i].score.yuwen,stu[i].score.math,
stu[i].score.english,stu[i].score.tiyu,stu[i].score.sum);
flag=0;
}
if
printf(“无此学号!n”);
printf(“是否继续查询?;
scanf(“%c”,&l);
if(l==’n’||l==’N’)
return;
else
system;
}
void del()
{
int i,j,flag=1;
char str[20],l; system;
modelmenu;
printf(“请输入要删除的学员学号:”);
scanf; getchar();
for(i=0;i if((strcmp(str,stu[i].num))==0)
{
printf(“%st%st%st%dt%.1ft%.1ft%.1ft%.1ft%.1fn”,
stu[i].num,stu[i].name,stu[i].sex,stu[i].score.yuwen,stu[i].score.math,
stu[i].score.english,stu[i].score.tiyu,stu[i].score.sum);
for(j=i;j stu[j]=stu[j+1];
flag=0;
printf(“删除成功!n”);
stnum–;
}
if
printf(“没有这个学生!n”);
printf(“是否继续删除?;
scanf(“%c”,&l);
if(l==’n’||l==’N’)
return;
else
{
system;
del();
}
}
void modi()
{
int i=0,flag=1;
char str[20],l; system;
modelmenu;
printf(“请输入要修改的学员学号:”);
scanf; getchar();
for(i=0;i if((strcmp(str,stu[i].num))==0)
break;
if
{
printline();
printf(“%st%st%st%dt%.1ft%.1ft%.1ft%.1ft%.1fn”,
stu[i].num,stu[i].name,stu[i].sex,stu[i].score.yuwen,stu[i].score.math,
stu[i].score.english,stu[i].score.tiyu,stu[i].score.sum);
printline();
printf(“n请输入修改内容n”);
printf(“请修改学生学号”);
scanf(“%s”,stu[i].num); getchar();
printf(“请修改学生姓名”);
scanf(“%s”,stu[i].name); getchar();
printf(“请修改学生性别”);
scanf(“%s”,stu[i].sex); getchar();
printf(“请修改学生年龄”);
scanf(“%d”,&stu[i].age); getchar();
printf(“请修改学生语文成绩”);
scanf(“%lf”,&stu[i].score.yuwen); getchar();
printf(“请修改学生数学成绩”);
scanf(“%lf”,&stu[i].score.math); getchar();
printf(“请修改学生英语成绩”);
scanf(“%lf”,&stu[i].score.english); getchar();
printf(“请修改学生体育成绩”);
scanf(“%lf”,&stu[i].score.tiyu); getchar();
printf(“修改后的学生信息为:n”);
printline();
printf(“%st%st%st%dt%.1ft%.1ft%.1ft%.1ft%.1fn”,
stu[i].num,stu[i].name,stu[i].sex,stu[i].score.yuwen,stu[i].score.math,
stu[i].score.english,stu[i].score.tiyu,stu[i].score.sum);
printline();
}
else
printf(“没有这个学生!n”);
printf(“是否继续修改?;
scanf(“%c”,&l);
if(l==’n’||l==’N’)
return;
else
{
system;
modi();
}
}
void sort()
{
struct Student t;
int i,k,p,x,flag=1;
double sum[5],g;
system;
sethint;
menu();
for(i=0;i sum[i]=stu[i].score.yuwen+stu[i].score.math+
stu[i].score.english+stu[i].score.tiyu;
for(k=0;k {
x=k;
for(p=k+1;p if(sum[x]>sum[p])
{
x=p;
g=sum[k]; sum[k]=sum[x]; sum[x]=g;
t=stu[k]; stu[k]=stu[x]; stu[x]=t;
}
}
}
void save()
{
FILE *fp; int i;
fp=fopen(“c:student.txt”,”w”);
system; sethint;
menu();
fprintf(fp,”学号t姓名t性别t年龄t语文t数学t英语t体育t总分n”);
for(i=5;i>0;i–)
if(stu[i].age!=0)
fprintf(fp,”%st%st%st%dt%.1ft%.1ft%.1ft%.1ft%.1fn”,
stu[i].num,stu[i].name,stu[i].sex,stu[i].score.yuwen,stu[i].score.math,
stu[i].score.english,stu[i].score.tiyu,stu[i].score.sum);
fclose;
}
void print()
{
int i; system;
modelmenu(“显示全部学生的信息”);
printf(“学号t姓名t性别t年龄t语文t数学t英语t体育t总分n”);
for(i=5;i>0;i–)
if(stu[i].age!=0)
printf(“%st%st%st%dt%.1ft%.1ft%.1ft%.1ft%.1fn”,
stu[i].num,stu[i].name,stu[i].sex,stu[i].score.yuwen,stu[i].score.math,
stu[i].score.english,stu[i].score.tiyu,stu[i].score.sum);
while
{
char l;
printf(“是否返回主菜单?;
scanf(“%c”,&l); getchar();
if(l==’Y’||l==’y’)
return;
}
}
void main()
{
int as; system(“color f5”);
do
{
menu();
printf(“Input>”);
sethint(“请按提示输入!”);
scanf(“%d”,&as); getchar();
if
as=0;
switch
{
case 0: sethint(“输入错误,请重新输入!”); break;
case 1: input(); break;
case 2: search(); break;
case 3: del(); break;
case 4: sort(); break;
case 5: modi(); break;
case 6: save(); break;
case 7: print(); break;
case 8: break;
default:menu();
}
system;
}
while;
}
澳门新葡萄京官网注册 1**