⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 教务管理.txt

📁 一个很好用的教务系统原代码 可以用来做课程设计
💻 TXT
📖 第 1 页 / 共 5 页
字号:
  int n=0,flag=1,sum=0,credit=0;
in1:if(n>3)                   /*连续四次输入错误密码*/
     { cprintf("Too many errors!");
       goto inEND;
     }  
    cprintf("\nInput the your keywords:");
    scanf("%s",key);

    cprintf("\n Input the class number:");
    scanf("%u",&no);
in2:cprintf("\n Input the student number:");
    scanf("%ld",&stu_num);
    if(((stu_num/100)%100)!=no)
            {   cprintf("Wrong numbers!");
                goto in2;
            }
    
    cprintf("\n Input the subject number:");
    scanf("%d",&subnum);
    for(p1=headp->next; p1!=NULL; p1=p1->next) 
    { 
      if(p1->no==no) break;/*找到班级入口*/
      else continue;
    }  
      
    if(p1==NULL){WarnCLA();goto inEND;} 
   for(p2=p1->first; p2!=NULL; p2=p2->next)
   {  
       if(p2->number!=stu_num)continue;
       else break;
   }                      /*找到学生*/ 
   if(p2==NULL){WarnSTU();goto inEND;}  
      if(strcmp(p2->STUkey,key))
             {   cprintf( "Wrong keywords! "); 
                 n++;
                 goto in1;
             }
   
          p2->average=0;
   for(p3=p2->first;p3!=NULL;p3=p3->next)
   { 
      if(p3->number==subnum)break;
      else continue;
   }                                        
   if(p3==NULL){WarnSUB();goto inEND;} 
            cprintf("\n ps_score:%-17u \t tx_score:%-16u \t un_score:%-14u", p3->ps_score,p3->tx_score,p3->un_score );
    iny:    cprintf("\t input the item you want to modify ( 1:ps_score   ,2:tx_score   ,3:un_score  ):     ");
            scanf("%d",&order);
          
            if(order==1)
            { 
    in3:  cprintf("\t Input %s's new ps_score:",p3->name);
              p3->ps_score=0;
              scanf("%u",&p3->ps_score);
               if(p3->ps_score>100||p3->ps_score<0)
              {   cprintf("Wrong numbers!");
                goto in3;
              }
               flag=0;
            }
        if(order==2)
            { flag=0;
    in4:  cprintf("\t Input %s's new tx_score:",p3->name);
              p3->tx_score=0;
              scanf("%u",&p3->tx_score);
              
               if(p3->tx_score>100||p3->tx_score<0)
              {   cprintf("Wrong numbers!");
                goto in4;
              }
            }
        if(order==3)
            { flag=0;
    in5:  cprintf("\t Input %s's new un_score:",p3->name);
              p3->un_score=0;
          scanf("%u",&p3->un_score);
               if(p3->un_score>100||p3->un_score<0)
              {   cprintf("Wrong numbers!");
                goto in5;
              }
            }
         for(p3=p2->first;p3!=NULL;p3=p3->next)
    {sum+=p3->un_score*p3->credit;
     credit+=p3->credit;
    }
    p2->average=(float)sum/credit;  
       if(flag) {
                    cprintf("\n Input error!-------------------------------------------------------------------");
                    goto iny;
                  }
    SUCESSES();
inEND:  return(headp);
}

struct CLASS *mod_STUkey(struct CLASS *headp)/*修改学生的密码*/
{
  struct CLASS  *p1;
  struct STUD *p2;
  long stunum;
  int i=0;
  char key[12];
  cprintf("Input your number:");
  scanf("%ld",&stunum);
  for(p1=headp->next;p1!=NULL;p1=p1->next)
  {if(p1->no==(stunum/100)%100)break;
   else continue;
  }
  if(p1==NULL){WarnSTU();goto inEND;}
  for(p2=p1->first;p2!=NULL;p2=p2->next)
  {if(p2->number==stunum)break;
   else continue;
  }
  if(p2==NULL){WarnSTU();goto inEND;}
inx:
  if(i>3){cprintf("Too many errors!");goto inEND;}
  cprintf("Input your keyword:");
  scanf("%s",key);
  if(strcmp(key,p2->STUkey)){cprintf("Wrong keyword!");i++;goto inx;}
  cprintf("Input your new keyword:");
  for(i=0;i<strlen(p2->STUkey);i++)
  p2->STUkey[i]=' ';
  scanf("%s",p2->STUkey);
  clrscr( );
  SUCESSES();
  inEND:return(headp);
}

struct CLASS * del_cla(struct CLASS *headp)/*删除班级*/
{
  long num;
  int ch,n=0;
  char key[12];
  int no;
  struct SUB * p3;
  struct STUD * p2;
  struct CLASS *p1,*last;
  in1:if(n>3)                       
     { cprintf("Too many errors!");
      goto   inEND;
     }  
    cprintf("\nInput the administer's keywords:");
    scanf("%s",key);

  do{
     cprintf("\n input the class number:");
     scanf("%u",&no);

    for(last=p1=headp->next;p1!=NULL;last=p1,p1=p1->next)
    { 
      if(p1->no==no) break;
      else continue;
    }  
      
    if(p1==NULL){WarnCLA();goto inEND;}        /*找到班级入口*/
       if(strcmp(headp->next->ADMkey,key))
             {   cprintf( "Wrong keywords! "); 
                 n++;
                 goto in1;
             }
        if(p1==headp->next)
        {
          if(p1->next!=NULL)  headp->next=p1->next;
          else headp->next=NULL;
        }
        else last->next=p1->next;
                                                                   
     for(p2=p1->first;p2!=NULL;p2=p2->next)    /*释放内存单元*/
        {for(p3=p2->first;p3!=NULL;p3=p3->next)
          free(p3);
          free(p2);
        }
     free(p1);
    cprintf("SUCESSES!Continue?(y/n)");
    while(isspace(ch=getchar()));
  }while(ch=='y'||ch=='Y');
inEND:  return(headp);
}

struct CLASS * del_stu(struct CLASS *headp)    /*删除学生*/
{
  long num;
  int ch,n=0;
  char key[12];
  int no,stu_num=0;
  struct STUD *last,*p2;
  struct CLASS *p1;
  struct SUB * p3;
  in1:if(n>3)
     { cprintf("Too many errors!");
       goto   inEND;
     }  
    cprintf("\nInput the administer's keywords:");
    scanf("%s",key);

do{
    cprintf("\n input the class number:");
    scanf("%u",&no);
in2:cprintf("\nInput the student's number :");
    scanf("%ld",&num);
    if((num/100)%100!=no)
    { cprintf("Wrong number!");
      goto in2;
    }
    for(p1=headp->next;p1!=NULL;p1=p1->next)
    {   
      
      if(p1->no==no) break;/*找到班级入口*/
      else continue;
    }  
      if(p1==NULL){WarnCLA();goto inEND;}   
      if(strcmp(p1->ADMkey,key))
             {   cprintf( "Wrong keywords! "); 
                 n++;
                 goto in1;
             } 
                                                                     
    
      for(p2=p1->first;p2!=NULL;last=p2,p2=p2->next)
      {   
           if(p2->number!=stu_num)continue;/*找到学生*/  
           else break;
      }  
        if(p2==NULL){WarnSTU();goto inEND;}      
        cprintf("\t class:%-10u \t name:%-16s \t birth place:%-23s",p1->no,p2->name,p2->bir_p);                                                             /*c2 is to delete*/
        if(p2!=p1->first)
          last->next=p2->next;
        else
      p1->first=p2->next;
        for(p3=p2->first;p3!=NULL;p3=p3->next)
        free(p3);
        free(p2); 
    cprintf("SUCESSES!Continue?(y/n)");
    while(isspace(ch=getchar()));
  }while(ch=='y'||ch=='Y');
inEND:  return(headp);
} 
struct CLASS * del_sbj(struct CLASS *headp)/*删除课程*/
{
  struct CLASS *p1;
  struct STUD *p2;
  struct SUB *p3,*last;
  int ch,n=0;
  char key[12];
  int no,sum=0,credit=0;
  int subnum;
  long stu_num;
  in1:if(n>3)                             /*多次输入错误密码自动退出*/
     { cprintf("Too many errors!");
       goto inEND;
     }  
    cprintf("\nInput the your keywords:");
    scanf("%s",key);

  do{
    cprintf("\n Input the class number:");
    scanf("%u",&no);
in2:cprintf("\n Input the student number:");
    scanf("%ld",&stu_num);
    if((stu_num/100)%100!=no)
    { cprintf("Wrong number!");
      goto in2;
    }
    cprintf("\n Input the subject number:");
    scanf("%u",&subnum);
   
    for(p1=headp->next;p1!=NULL;p1=p1->next)
    { 
      if(p1->no==no) break;                 /*找到班级入口*/
      else continue;
    } 
    if(p1==NULL){WarnCLA();goto inEND;}    
    for(p2=p1->first;p2!=NULL;p2=p2->next)
    {  
       if(p2->number!=stu_num)continue;
       else break;
    }  
    if(p2==NULL){WarnSTU();goto inEND;}        /*找到学生*/     
       if(strcmp(p2->STUkey,key))
             {   cprintf( "Wrong keywords! "); 
                 n++;
                 goto in1;
             }
    for(p3=p2->first;p3!=NULL;last=p3,p3=p3->next)
    { 
      if(p3->number!=subnum)continue;
      else break;
    }   
     
    if(p3==NULL){WarnSUB();goto inEND;}    /*找到课程入口*/     
          cprintf("\n\t number:%-16u \t name:%-11s\t score:%4u \t credit:%-14u",p3->number,p3->name,p3->un_score,p3->credit); 
          if(p3!=p2->first)           /*p3 is not the head node*/
             last->next=p3->next;
          else
             p2->first=p3->next;
          free(p3);
          p2->subjects--;
    for(p3=p2->first;p3!=NULL;p3=p3->next)
    {sum+=p3->un_score*p3->credit;
     credit+=p3->credit;
    }
    p2->average=(float)sum/credit;  
    cprintf("\t Continue?(y/n)");
    while(isspace(ch=getchar()));
  }while(ch=='y'||ch=='Y');
   clrscr( ); 
inEND:  return(headp);
}

struct CLASS * ins_cla(struct CLASS *headp)/*插入班级*/
{ 
     char ch;
     int n=0;
     char Licence[12];
     struct CLASS *p1,*l1,*t1; 
in1: if(n>3)
     { cprintf("Too many errors!");

      goto inEND;
     }  
     cprintf("\nInput the administer's keywords:");/*输入管理员密码*/
     scanf("%s",Licence);

     if(strcmp(headp->next->ADMkey,Licence))
             {   cprintf( "Wrong keywords! "); 
                 n++;
                 goto in1;
             }
  
inx:  
     p1=(struct CLASS*)malloc(sizeof(struct CLASS));
     cprintf("\n input the class number :");
     scanf("%u",&p1->no);
    
  for(t1=headp->next;t1!=NULL;t1=t1->next)/*查找班级入口*/
     if(p1->no==t1->no)
     {
        cprintf("\t The class is exist! continue?(y/n)");
        while(isspace(ch=getchar()));
        if(ch=='y'||ch=='Y')   
        goto inx;
        else goto inEND;
     }
    if(headp->next==NULL)
    {      p1->next=NULL;/*班级不存在*/
           headp->next=p1;
           p1->classes=0;
           goto iny;
    }
    if(p1->no>headp->next->no)
    {      p1->next=headp->next;/*作为链头*/
           headp->next=p1;
    }
    else
    {
        for(t1=headp->next;t1->no>p1->no;l1=t1,t1=t1->next)
        {  if(t1->next==NULL)
           {  p1->next=NULL; 
              t1->next=p1;/*插入作为链尾*/
              goto iny;
           }
           else   continue;
        }                    
        p1->next=t1;
        l1->next=p1;      /*插在中间*/
    }

iny:  cprintf("\n input the administer's keywords:");
      scanf("%s",p1->ADMkey);
      cprintf("Sucsses!");
      for(t1=headp->next;t1!=NULL;t1=t1->next)
      t1->classes++;
      p1->students=0;
      p1->first=NULL;
      clrscr( );
      SUCESSES();
inEND:     return(headp);
}
struct CLASS * ins_stu(struct CLASS *headp)/*插入学生*/
{  char ch,Ch,c;
   char CH[12];
   char Licence[12];
   int n=0,flag=1;
   int no;
   struct CLASS *p11,*p12,*last1;
   struct STUD *p21,*p22,*p2,*last;  
   p2=(struct STUD*)malloc(sizeof(struct STUD));
   cprintf("\n input the class number:");
   scanf("%u",&no);
in2:cprintf("\t input the student's number :");
    scanf("%ld",&p2->number);
    if((p2->number/100)%100!=no)
    {  cprintf("Wrong number!");
       goto in2;
    }
inx:  
   in1:if(n>3)           /*多次输入错误密码*/
     { 
       cprintf("Too many errors!");
       goto inEND;
     }
    cprintf("\nInput the administer's keywords:");
    scanf("%s",Licence);
   
   

   for(p11=headp->next; p11!=NULL;last1=p11, p11=p11->next) /*p11为遍历指针*/
   {
     if (p11->no == no)
     {
    p12 = p11;
    break;
     }  
     else continue;                            /*p12为班级入口*/
   }
   if(last1==NULL){WarnCLA();goto inEND;}
   if(strcmp(p12->ADMkey,Licence))
             {   
                 cprintf( "Wrong keywords! "); 
                 n++;
                 goto in1;
             }

   for(p21=p12->first; p21!=NULL; p21=p21->next)/*p21为遍历指针*/
   {
  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -