学生成绩管理系统(1)

本系统由edt.c、file.c、find.c、obf.c、pcgate.c、MAIN.C组成,现在给出所有源码。
/*edt.c*/
struct _stu *_find(struct _stu *p2,char *a)      /*查找数据*/
{int c;
void *p=malloc(10);
struct _stu *p1=(struct _stu *)malloc(sizeof(struct _stu)),*p3,*p4;p4=p1;
printf("
Which information do you know about him,please choose:
");
printf("1:no.
2:name.
3:score.
");
scanf("%d",&c);while(getchar()!=10);
while(c!=1&&c!=2&&c!=3)
{printf("Choosing ERORR!Please choose again:");
  scanf("%d",&c);while(getchar()!=10);
}if(c==3)
{printf("
Please choose which score do you know him:
");
  printf("1:math   2:english  3:computer
");
  printf("4:physics   5:totall
");
  scanf("%d",&c);while(getchar()!=10);
  while(c!=1&&c!=2&&c!=3&&c!=4&&c!=5)
  {printf("Choosing ERORR!Please choose again:");
   scanf("%d",&c);while(getchar()!=10);
  }c+=2;
}if(c==1) {printf("
Please input his no:");scanf("%9s",p);}
else if(c==2) {printf("
Please input his name:");scanf("%9s",p);}
else
{if(c==3) printf("
Please input his score of math:");
  else if(c==4) printf("
Please input his score of english:");
  else if(c==5) printf("
Please input his score of computer:");
  else if(c==6) printf("
Please input his score of physics:");
  else printf("
Please input his score of totall:");
  scanf("%f",p);while(getchar()!=10);
}*a=0;
if(c==1)while(p2)
{if(!strcmp((char *)p,p2->no))
  {copy((char *)p1,(char *)p2,sizeof(struct _stu)-2);
   p1->next=(struct _stu *)malloc(sizeof(struct _stu));
   p3=p1;p1=p1->next;(*a)++;
  }p2=p2->next;
}if(c==2)while(p2)
{if(!strcmp((char *)p,p2->name))
  {copy((char *)p1,(char *)p2,sizeof(struct _stu)-2);
   p1->next=(struct _stu *)malloc(sizeof(struct _stu));
   p3=p1;p1=p1->next;(*a)++;
  }p2=p2->next;
}if(c==3)while(p2)
{if(*(float *)p==p2->score.math)
{copy((char *)p1,(char *)p2,sizeof(struct _stu)-2);
   p1->next=(struct _stu *)malloc(sizeof(struct _stu));
   p3=p1;p1=p1->next;(*a)++;
  }p2=p2->next;
}if(c==4)while(p2)
{if(*(float *)p==p2->score.english)
{copy((char *)p1,(char *)p2,sizeof(struct _stu)-2);
   p1->next=(struct _stu *)malloc(sizeof(struct _stu));
   p3=p1;p1=p1->next;(*a)++;
  }p2=p2->next;
}if(c==5)while(p2)
{if(*(float *)p==p2->score.computer)
  {copy((char *)p1,(char *)p2,sizeof(struct _stu)-2);
   p1->next=(struct _stu *)malloc(sizeof(struct _stu));
   p3=p1;p1=p1->next;(*a)++;
  }p2=p2->next;
}if(c==6)while(p2)
{if(*(float *)p==p2->score.physics)
  {copy((char *)p1,(char *)p2,sizeof(struct _stu)-2);
   p1->next=(struct _stu *)malloc(sizeof(struct _stu));
   p3=p1;p1=p1->next;(*a)++;
  }p2=p2->next;
}if(c==7)while(p2)
{if(*(float *)p==p2->score.totall)
  {copy((char *)p1,(char *)p2,sizeof(struct _stu)-2);
   p1->next=(struct _stu *)malloc(sizeof(struct _stu));
   p3=p1;p1=p1->next;(*a)++;
  }p2=p2->next;
}p3->next=0;
if(*a) return p4;
else return 0;
}
void sort (struct _stu *head,int i)  /*按特定规则排序*/
{char j,m,n;
struct _stu *p1=head,a;
if(!i)
{printf("Please choose which one do you want sort by:
");
  printf("1:no.  2:name   3.score
");
  scanf("%d",&i);while(getchar()!=10);
  while(i!=1&&i!=2&&i!=3)
  {printf("Choosing ERORR!Please choose again:");
   scanf("%d",&i);while(getchar()!=10);
  }if(i==3)
  {printf("Please choose which score do you want to sort by:
");
   printf("1:math  2:english  3:computer  4:physics
5:totall");
   scanf("%d",&i);while(getchar()!=10);
   while(i!=1&&i!=2&&i!=3&&i!=4&&i!=5)
   {printf("Choosing ERORR!Please choose again:");
    scanf("%d",&i);while(getchar()!=10);
   }i=i+2;
  }                                
}for(j=0;p1;j++)
p1=p1->next;
p1=head;
if(i==1)
for(m=1;m<j;m++)
{for(n=0;n<j-m;n++)
  {if(strcmp(p1->no,p1->next->no)>0)
   {copy((char *)&a,(char *)p1,sizeof(struct _stu)-2);
    copy((char *)p1,(char *)p1->next,sizeof(struct _stu)-2);
    copy((char *)p1->next,(char *)&a,sizeof(struct _stu)-2);
   }p1=p1->next;
  }p1=head;
}else if(i==2)
for(m=1;m<j;m++)
{for(n=0;n<j-m;n++)
  {if(strcmp(p1->name,p1->next->name)>0)
   {copy((char *)&a,(char *)p1,sizeof(struct _stu)-2);
    copy((char *)p1,(char *)p1->next,sizeof(struct _stu)-2);
    copy((char *)p1->next,(char *)&a,sizeof(struct _stu)-2);
   }p1=p1->next;
  }p1=head;
}else if(i==3)
for(m=1;m<j;m++)
{for(n=0;n<j-m;n++)
  {if(p1->score.math<p1->next->score.math)
   {copy((char *)&a,(char *)p1,sizeof(struct _stu)-2);
    copy((char *)p1,(char *)p1->next,sizeof(struct _stu)-2);
    copy((char *)p1->next,(char *)&a,sizeof(struct _stu)-2);
   }p1=p1->next;
  }p1=head;
}else if(i==4)
for(m=1;m<j;m++)
{for(n=0;n<j-m;n++)
  {if(p1->score.english<p1->next->score.english)
   {copy((char *)&a,(char *)p1,sizeof(struct _stu)-2);
    copy((char *)p1,(char *)p1->next,sizeof(struct _stu)-2);
    copy((char *)p1->next,(char *)&a,sizeof(struct _stu)-2);
   }p1=p1->next;
  }p1=head;
}else if(i==5)
for(m=1;m<j;m++)
{for(n=0;n<j-m;n++)
  {if(p1->score.computer<p1->next->score.computer)
   {copy((char *)&a,(char *)p1,sizeof(struct _stu)-2);
    copy((char *)p1,(char *)p1->next,sizeof(struct _stu)-2);
    copy((char *)p1->next,(char *)&a,sizeof(struct _stu)-2);
   }p1=p1->next;
  }p1=head;
}else if(i==6)
for(m=1;m<j;m++)
{for(n=0;n<j-m;n++)
  {if(p1->score.physics<p1->next->score.physics)
   {copy((char *)&a,(char *)p1,sizeof(struct _stu)-2);
    copy((char *)p1,(char *)p1->next,sizeof(struct _stu)-2);
    copy((char *)p1->next,(char *)&a,sizeof(struct _stu)-2);
   }p1=p1->next;
  }p1=head;
}else if(i==7)
for(m=1;m<j;m++)
{for(n=0;n<j-m;n++)
  {if(p1->score.totall<p1->next->score.totall)
   {copy((char *)&a,(char *)p1,sizeof(struct _stu)-2);
    copy((char *)p1,(char *)p1->next,sizeof(struct _stu)-2);
    copy((char *)p1->next,(char *)&a,sizeof(struct _stu)-2);
   }p1=p1->next;
  }p1=head;
}
}
char del(struct _stu *head,struct _stu *p)  /*删除记录*/
{char a;
struct _stu *p1,*p2,*p3;
while(p)
{a=1;p1=p2=head;
  while(p2)
  {if(compare((char *)p,(char *)p2,sizeof(struct _stu)-2))
   if(a==1) if(head->next==0) return 0;else
   {copy((char *)p2,(char *)p2->next,sizeof(struct _stu)-2);
    p3=p2->next;p2->next=p2->next->next;free(p3);
   }else {p3=p1->next;p1->next=p2->next;free(p3);}
   p1=p2;p2=p2->next;a++;
  }p=p->next;
}return 1;
}
void add(struct _stu *p) /*增加记录*/
{char c='Y',i=1;
void Input(struct _stu *,char);
while(p->next)
  p=p->next;
while(c=='Y'|c=='y')
{p=p->next=(struct _stu *)malloc(sizeof(struct _stu));
  Input(p,i);
  printf("Do you want to add another record?(Y/N)");
  scanf(" %c",&c);while(getchar()!=10);
  while(c!='y'&&c!='Y'&&c!='N'&&c!='n')
  {printf("Choosing ERORR!Please choose again:");
   scanf("%c",&c);while(getchar()!=10);
  }i++;
}p->next=0;
}
/*file.c*/
# include <stdio.h>
# include <string.h>
# include <malloc.h>
struct _mima            /*类型声明*/
{char no[16];
char mima[16];
struct _mima *next;
};
struct _stu
{char no[10];
char name[10];
struct {float math;float english;float computer;
    float physics;float average;float totall;} score;
struct _stu *next;
};
char compare(char *,char *,char);      /*函数原型*/
void copy(char *,char *,char);
void output(struct _stu *);
void Input(struct _stu *,char);
struct _stu *_find(struct _stu *,char *);
void sort (struct _stu *,int);
char del(struct _stu *,struct _stu *);
void add(struct _stu *);
struct _stu *fail(struct _stu *,char *,char);
struct _stu *top(struct _stu *,char *,char);
void fin(struct _stu *);
void Ope(struct _stu *,char *,char);
void Bui(struct _stu *,char *,char);
char pcg(void);
void chg(char);
void mag(void);
void Input(struct _stu *p1,char i)     /*输入函数*/
{float a;
printf("Please input the %d student's no.:",i);
scanf("%s",p1->no);while(getchar()!=10);
printf("Please input the %d student's name:",i);
scanf("%s",p1->name);while(getchar()!=10);
printf("Please input the %d student's score:
Math:",i);
scanf("%f",&a);while(getchar()!=10);
p1->score.math=a;
printf("English:");
scanf("%f",&a);while(getchar()!=10);
p1->score.english=a;
printf("Computer:");
scanf("%f",&a);while(getchar()!=10);
p1->score.computer=a;
printf("Physics:");
scanf("%f",&a);while(getchar()!=10);
p1->score.physics=a;
p1->score.totall=p1->score.math+p1->score.english+p1->score.computer+p1->score.physics;
p1->score.average=p1->score.totall/4;
}
void output(struct _stu *p1)   /*输出函数*/
{int i;
printf("      学号       姓名   数学   英语 计算机   物理    平均分      总分
");
for(i=0;p1!=0;i++)
{printf("%9s  %9s  %5.1f  ",p1->no,p1->name,p1->score.math);
  printf("%5.1f  %5.1f  ",p1->score.english,p1->score.computer);
  printf("%5.1f  %7.3f   %7.3f
",p1->score.physics,p1->score.average,p1->score.totall);
  p1=p1->next;
}
}
void copy(char *a,char *b,char c)  /*数据复制*/
{char i;
for(i=0;i<c;i++)
*(a++)=*(b++);
}
char compare(char *a,char *b,char c)   /*数据比较*/
{char i;
for(i=0;i<c;i++)
  if(*(a++)!=*(b++)) break;
if(i==c) return 1;
else return 0;
}
/*find.c*/
struct _stu *fail(struct _stu *head,char *a,char c)  /*查找不及格记录*/
{struct _stu *p1=head,*p2;
*a=0;sort(head,c+2);
if(c==1)
while(p1!=0)
{if(p1->score.math<60)
  {p2=p1;break;
  }p1=p1->next;
}else if(c==2)
while(p1!=0)
{if(p1->score.english<60)
  {p2=p1;break;
  }p1=p1->next;
}else if(c==3)
while(p1!=0)
{if(p1->score.computer<60)
  {p2=p1;break;
  }p1=p1->next;
}else if(c==4)
while(p1!=0)
{if(p1->score.physics<60)
  {p2=p1;break;
  }p1=p1->next;
}else
while(p1!=0)
{if(p1->score.totall<60)
  {p2=p1;break;
  }p1=p1->next;
}for(p1=p2;p2;p2=p2->next)
(*a)++;
return p1;
}
struct _stu *top(struct _stu *p2,char *i,char c)        /*查找高分记录前五名*/
{struct _stu *p1=(struct _stu*)malloc(sizeof(struct _stu)),*p3;
sort(p2,c+2);p3=p1;
for(*i=1;*i<5&&p2->next;(*i)++,p2=p2->next)
{copy((char *)p1,(char *)p2,sizeof(struct _stu)-2);
  p1=p1->next=(struct _stu *)malloc(sizeof(struct _stu));
}copy((char *)p1,(char *)p2,sizeof(struct _stu)-2);
p1->next=0;return p3;
}
void fin(struct _stu *head)       /*主查询系统*/
{char b,ii,c='y';
int a;
struct _stu *p1,*p2=head;
while(c=='y'||c=='Y')
{printf("Now please choose:
1.find someone you know one of his message.
");
  printf("2.find someone by adition.
3.exit.
");
  scanf("%d",&a);while(getchar()!=10);
  while(a!=1&&a!=2&&a!=3)
  {printf("Choosing ERORR!Please choose again:");
   scanf("%d",&a);while(getchar()!=10);
  }if(a==1) p1=_find(head,&b);
  else if(a==2)
  {printf("Please choose which adition:
1.find the top student step by step.
");
   printf("2.find the failing student.
3.see the sorted line.
");
   scanf("%d",&a);while(getchar()!=10);
   while(a!=1&&a!=2&&a!=3)
   {printf("Choosing ERORR!Please choose again:");
    scanf("%d",&a);while(getchar()!=10);
   }if(a==1)
   {printf("Please choose:
1.math top student
2.english top student
");
    printf("3.coputer top student
4.physics top student
5.totall top student
");
    scanf("%d",&a);while(getchar()!=10);
    while(a!=1&&a!=2&&a!=3&&a!=4&&a!=5)
    {printf("Choosing ERORR!Please choose again:");
     scanf("%d",&a);while(getchar()!=10);
    }p1=top(head,&b,a);a=2;
   }else if(a==2)
   {printf("Please choose:
1.math failling students
");
    printf("2.english failling students
3.computer failling students
");
    printf("4.physics failling students
5.totall failling students
");
    scanf("%d",&a);while(getchar()!=10);
    while(a!=1&&a!=2&&a!=3&&a!=4&&a!=5)
    {printf("Choosing ERORR!Please choose again:");
     scanf("%d",&a);while(getchar()!=10);
    }p1=fail(head,&b,a);a=2;
   }else
   {char b='y';
    while(b=='y'||b=='Y')
    {printf("Please choose:
1.sorted by math score
");
     printf("2.sorted by english score
3.sorted by computer score
");
     printf("4.sorted by physics score
5.sorted by totall score
");
     scanf("%d",&a);while(getchar()!=10);
     while(a!=1&&a!=2&&a!=3&&a!=4&&a!=5)
     {printf("Choosing ERORR!Please choose again:");
      scanf("%d",&a);while(getchar()!=10);
     }sort(head,a+2);
     printf("The sorted line is as follows:
");
     output(head);
     printf("Do you want to see the sorted line by another adition?");
     scanf(" %c",&b);while(getchar()!=10);
     while(b!='y'&&b!='Y'&&b!='n'&&b!='N')
     {printf("Choosing ERORR!Please choose again:");
      scanf(" %c",&b);while(getchar()!=10);
     }
    }a=3;
   }
  }if(a!=3)
  {struct _stu px;
   printf("
%d records found which is as follows!

",b);
   if(b)
   {output(p1);
    printf("------------------------------------------------------

");
   }for(ii=1;ii<=b;ii++)
   {printf("Press enter key to continue------");
    while(getchar()!=10);
    copy((char *)(&px),(char *)p1,sizeof(struct _stu)-2);
    printf("
The no. %d record is as follows:
",ii);
    px.next=0;output(&px);
    printf("
Do you want to change any message of this record?");
    scanf(" %c",&a);while(getchar()!=10);
    while(a!='y'&&a!='Y'&&a!='n'&&a!='N')
    {printf("Choosing ERORR!Please choose again:");
     scanf(" %c",&a);while(getchar()!=10);
    }if(a=='Y'||a=='y')
    {while(compare((char *)p2,(char *)&px,sizeof(struct _stu)-2)==0) p2=p2->next;
     while(a=='y'||a=='Y')
     {printf("
Please choose which message do you want to edit?
1:no..        2:name.");
      printf("        3:math.
4:english.    5:computer.    6:physics.
");
      scanf("%d",&a);while(getchar()!=10);
      while(a!=1&&a!=2&&a!=3&&a!=4&&a!=5&&a!=6)
      {printf("Choosing ERORR!Please choose again:");
       scanf("%d",&a);while(getchar()!=10);
      }switch(a)
      {case 1:printf("Please input his no.:");scanf("%9s",px.no);while(getchar()!=10);
              strcpy(p2->no,px.no);break;
       case 2:printf("Please input his name:");scanf("%9s",px.name);while(getchar()!=10);
              strcpy(p2->name,px.name);break;
       case 3:printf("Please input his math score:");scanf("%f",&px.score.math);
              while(getchar()!=10);p2->score.math=px.score.math;break;
       case 4:printf("Please input his english score:");scanf("%f",&px.score.english);
              while(getchar()!=10);p2->score.english=px.score.english;break;
       case 5:printf("Please input his computer score:");scanf("%f",&px.score.computer);
              while(getchar()!=10);p2->score.computer=px.score.computer;break;
       case 6:printf("Please input his physics score:");scanf("%f",&px.score.physics);
              while(getchar()!=10);p2->score.physics=px.score.physics;break;
      }p2->score.totall=p2->score.math+p2->score.english+p2->score.computer+p2->score.physics;
      px.score.totall=px.score.math+px.score.english+px.score.computer+px.score.physics;
      p2->score.average=p2->score.totall/4;px.score.average=px.score.totall/4;
      printf("
Now this record is as follows:
");output(&px);
      printf("Do you want to edit another messsage of this record?");
      scanf(" %c",&a);while(getchar()!=10);
      while(a!='y'&&a!='Y'&&a!='n'&&a!='N')
      {printf("Choosing ERORR!Please choose again:");
       scanf(" %c",&a);while(getchar()!=10);
      }
     }
    }printf("Now please choose how do you want to do it?
");
    printf("1:See this record in the all records.
2:Delete this record.
3.Exit
");
    scanf("%d",&a);while(getchar()!=10);
    while(a!=1&&a!=2&&a!=3)
    {printf("Choosing ERORR!Please choose again:");
     scanf("%d",&a);while(getchar()!=10);
    }if(a==1)
    {char i=0,j=0,m=0,n=0,k=0;
     for(p2=head;p2;p2=p2->next)
     {if(p2->score.math>p1->score.math) i++;
      if(p2->score.english>p1->score.english) j++;
      if(p2->score.computer>p1->score.computer) m++;
      if(p2->score.physics>p1->score.physics) n++;
      if(p2->score.totall>p1->score.totall) k++;
     }printf("There are:
%d records more then this student in math
",i);
     printf("%d records more then this student in english
",j);
     printf("%d records more then this student in computer
",m);
     printf("%d records more then this student in physics
",n);
     printf("%d records more then this student in totall
",k);
     printf("Do you want to delete this record?");
     scanf(" %c",&a);while(getchar()!=10);
     while(a!='y'&&a!='Y'&&a!='n'&&a!='N')
     {printf("Choosing ERORR!Please choose again:");
      scanf(" %c",&a);while(getchar()!=10);
     }
    }if(a==2||a=='y'||a=='Y')
    {del(head,&px);
     printf("OK,it has been deleted!
");
    }p1=p1->next;
   }
  }printf("
-------------------------------------------------------

");
  printf("Do you want to find another record and edit it?");
  scanf(" %c",&c);while(getchar()!=10);
  while(c!='y'&&c!='Y'&&c!='n'&&c!='N')
  {printf("Choosing ERORR!Please choose again:");
   scanf(" %c",&c);while(getchar()!=10);
  }
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值