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

📄 main.c

📁 关于学生数据管理系统用C编的代码
💻 C
📖 第 1 页 / 共 4 页
字号:
      	            {
      	                flag3=1;
    	                goto sameName3;  /*可能有重名的学生*/
    	            }
    	              break;
    	    default: printf("\nNo correct choosen!\n");
    	             exit(-1);
        }
      }
      	else
      {
      	  printf("The existent score of Math: %d\tModify to: ",currentStud->scores->Math);
      	  gets(sco);
      	  if(strcmp(sco,"")==0)
      	{
      	}
      	  else
      	{
      	    currentStud->scores->Math=atoi(sco);
      	}
      	  printf("The existent score of Physics: %d\tModify to: ",currentStud->scores->Physics);
      	  gets(sco);
      	  if(strcmp(sco,"")==0)
      	{
      	}
      	  else
      	{
      	    currentStud->scores->Physics=atoi(sco);
      	}
      	  printf("The existent score of English: %d\tModify to: ",currentStud->scores->English);
      	  gets(sco);
      	  if(strcmp(sco,"")==0)
      	{
      	}
      	  else
      	{
      	    currentStud->scores->English=atoi(sco);
      	}
      	  printf("The existent score of Computer: %d\tModify to: ",currentStud->scores->Computer);
      	  gets(sco);
      	  if(strcmp(sco,"")==0)
      	{
      	}
      	  else
      	{
      	    currentStud->scores->Computer=atoi(sco);
      	}
      	      	  
    	  saveFile();
    	  printf("\nModify the student's scores successfully!\n");
    	  printf("Goto the main page!\n");
    	  getchar();
    	  mainPage();
      }
    }
      else
    {
      	frontStud=currentStud;
    	currentStud=frontStud->next;
    	if(currentStud->next==NULL&&strcmp(currentStud->name,studentName)==0)
      {                           /*他已经是最后一个了,不可能还有重名的*/
    	  printf("\nNo other \"%s\"!\n",studentName);
      	  printf("Go to the main page!\n");
      	  getchar();
      	  mainPage();
      }
      	 else
      {
      	   flag3=1;
    	   goto sameName3;  /*可能有重名的学生*/
      }
    }
}


/*为所有学生排名的函数*/
    int rankAll()
{      
      struct stud *headStudent;
      struct stud *frontStudent;
      struct stud *currentStudent;
      struct stud *compStudent;
      int position=0;
      int temp=0,tt=1;
      int currentAve=0;
      int compAve=0;
      int flag6=2;
      
     /*创建一个暂时性的链表,并按平均分存储所有学生*/
      clrscr();
      
      currentStudent=(struct stud *)malloc(sizeof(struct stud)); /*建立表头*/
      if(currentStudent==NULL)
    {
      	printf("Can't assign the place for the temporary first student!\n");
      	exit(-1);
    }
      *currentStudent=*(head->student);  
      headStudent=currentStudent; 
      headStudent->next=NULL;  /*成功建立表头*/
      
      for(currentClass=head;currentClass!=NULL;)  /*按顺序建立表的其他部分*/
    {
    	for(currentStud=currentClass->student;currentStud!=NULL;)
      {
      	  if(tt==1)
      	    goto xx;
      	  compStudent=(struct stud *)malloc(sizeof(struct stud)); /*保存一个被比较学生的数据*/
      	  if(compStudent==NULL)
      	{
      	    printf("Can't assign the place for the compStudent!\n");
      	    exit(-1);
      	}
      	  *compStudent=*currentStud;
      	  if(compStudent->scores!=NULL)
      	    compAve=compStudent->scores->average;
      	  else
      	    compAve=0;
      	  
      	  currentStudent=headStudent;
      	  if(currentStudent->scores!=NULL)
      	    currentAve=currentStudent->scores->average;
      	  else
      	    currentAve=0;
      	  
      	  for(;currentAve>=compAve&&currentStudent!=NULL;)   /*寻找插入点*/
      	{           
      	    frontStudent=currentStudent;
      	    currentStudent=frontStudent->next;
      	    if(currentStudent->scores!=NULL)
      	      currentAve=currentStudent->scores->average;
      	    else
      	      currentAve=0;
      	}
      	  if(currentAve>=compAve&&currentStudent==NULL)  /*插到最后一个*/
      	{
      	    frontStudent->next=compStudent;
      	    compStudent->next=NULL;
      	}
      	  if(currentAve<compAve&&currentStudent!=NULL)  /*插到中间*/
      	{
      	    frontStudent->next=compStudent;
      	    compStudent->next=currentStudent;
      	}
      	  if(currentAve<compAve&&headStudent==currentStudent)  /*插成为第一个*/
      	{
      	    headStudent=compStudent;
      	    compStudent->next=currentStudent;
      	}
      	  
      	  xx:
      	  tt=2;
      	  frontStud=currentStud;
      	  currentStud=frontStud->next;
      }
        frontClass=currentClass;
        currentClass=frontClass->next;
    }   /*成功建立链表*/
      
     /*输出结果*/
      printf("Position\tID\t\tName\tAverage\tMath\tPhysics\tEnglish\tComputer\n\n");
      flag6=2;
      for(currentStudent=headStudent,position=temp=1;currentStudent!=NULL;temp++,flag6++)
    {
    	if(currentStudent->scores==NULL&&flag6!=1)
    	  position=temp;
    	if(currentStudent->scores!=NULL)
      {
      	  if(frontStudent->scores->average==currentStudent->scores->average) /*并列成绩*/
      	{
        }
          else
        {
            position=temp;
        }
      }
        else                                    /*并列成绩*/
      {
      }
    	if(currentStudent->scores!=NULL)
      {
      	  if(strlen(currentStudent->ID)>=8)
      	{
    	    printf("%d\t\t%s\t%s\t%d\t%d\t%d\t%d\t%d\n",position,currentStudent->ID,currentStudent->name,
    	          currentStudent->scores->average,currentStudent->scores->Math,
    	          currentStudent->scores->Physics,currentStudent->scores->English,
    	          currentStudent->scores->Computer);
    	}
    	  else
    	{
    	    printf("%d\t\t%s\t\t%s\t%d\t%d\t%d\t%d\t%d\n",position,currentStudent->ID,currentStudent->name,
    	          currentStudent->scores->average,currentStudent->scores->Math,
    	          currentStudent->scores->Physics,currentStudent->scores->English,
    	          currentStudent->scores->Computer);
    	}
      }
        else
      {
      	  if(strlen(currentStudent->ID)>=8)
      	{
      	    printf("%d\t\t%s\t%s\t%d\t%d\t%d\t%d\t%d\n",position,currentStudent->ID,currentStudent->name,
      	          0,0,0,0,0);
      	}
      	  else
      	{
      	    printf("%d\t\t%s\t\t%s\t%d\t%d\t%d\t%d\t%d\n",position,currentStudent->ID,currentStudent->name,
      	          0,0,0,0,0);
      	}
      }
    	frontStudent=currentStudent;
    	currentStudent=frontStudent->next;
    	
    	if(temp%20==0)                      /*分屏显示*/
      {
      	  printf("\nPut \"Enter\" to continue showing: ");
      	  getchar();
      	  clrscr();
      }
        flag6=1;
    }
    
      printf("\nGo to the main page! ");
      getchar();
      mainPage();
}


/*统计各班各平均成绩的函数*/
    int classAverage()
{
      int numStud=0;
      int math=0;
      int physics=0;
      int english=0;
      int computer=0;
      int whole=0;
      int temp7=0;
      
      clrscr();
      printf("\n\n");
      printf("ClassNumber\tMath\tPhysics\tEnglish\tComputer\tTotalAverage\n\n");
      for(currentClass=head,temp7=1;currentClass!=NULL;temp7++)
    {
    	for(currentStud=currentClass->student,numStud=0;currentStud!=NULL;numStud++)
      {
      	  if(currentStud->scores!=NULL)
      	{
      	    math+=currentStud->scores->Math;
      	    physics+=currentStud->scores->Physics;
      	    english+=currentStud->scores->English;
      	    computer+=currentStud->scores->Computer;
      	    whole+=currentStud->scores->average;
      	}
      	  else                /*说明此同学没有任何成绩*/
      	{
      	}
      	
      	  frontStud=currentStud;
      	  currentStud=frontStud->next;
      }
        math/=numStud;
        physics/=numStud;
        english/=numStud;
        computer/=numStud;
        whole/=numStud;
        
        if(strlen(currentClass->ID)>=8)
      {
          printf("%s\t%d\t%d\t%d\t%d\t\t%d\n",currentClass->ID,math,physics,english,
                  computer,whole);
      }
        else
      {
      	  printf("%s\t\t%d\t%d\t%d\t%d\t\t%d\n",currentClass->ID,math,physics,english,
                  computer,whole);
      }
      
        math=0;
        physics=0;
        english=0;
        computer=0;
        whole=0;
        numStud=0;
        frontClass=currentClass;
        currentClass=frontClass->next;
        
        if(temp7%20==0)                      /*分屏显示*/
      {
      	  printf("\nPut \"Enter\" to continue showing: ");
      	  getchar();
      	  clrscr();
      }
    }
    
      printf("\nGo to the main page! ");
      getchar();
      mainPage();
}


/*列不及格人名单的函数*/
    int showFailed()
{
      int math1=0;
      int physics1=0;
      int english1=0;
      int computer1=0;
      int temp8=1;
      
      clrscr();
      printf("\n\nFailedName\tID\t\tInformation\n\n");
      for(currentClass=head;currentClass!=NULL;)
    {
    	for(currentStud=currentClass->student;currentStud!=NULL;)
      {
      	  math1=0;
          physics1=0;
          english1=0;
          computer1=0;
          
      	  if(currentStud->scores!=NULL)
      	{
      	    math1=currentStud->scores->Math;
            physics1=currentStud->scores->Physics;
            english1=currentStud->scores->English;
            computer1=currentStud->scores->Computer;
            
      	    if(math1<60||physics1<60||english1<60||computer1<60)
      	  {
      	      temp8++;
      	      if(strlen(currentStud->name)>=8)   /*输入姓名和学号*/
      	    {
      	        printf("%s\t",currentStud->name);
      	    }
      	      else
      	    {
      	    	printf("%s\t\t",currentStud->name);
      	    }
      	      if(strlen(currentStud->ID)>=8)
      	    {
      	    	printf("%s\t",currentStud->ID);
      	    }
      	      else
      	    {
      	    	printf("%s\t\t",currentStud->ID);
      	    }
      	    
      	      if(math1<60)        /*输出不及格的科目和成绩*/
      	    {
      	    	printf("Math:%d\t",math1);
      	    }
      	      if(physics1<60)
      	    {
      	    	printf("Physics:%d\t",physics1);
      	    }
      	      if(english1<60)
      	    {
      	    	printf("English:%d\t",english1);
      	    }
      	      if(computer1<60)
      	    {
      	    	printf("Computer:%d\t",physics1);
      	    }
      	      putchar('\n');
      	  }
      	}
      	  if(temp8%20==0)                      /*分屏显示*/
        {
      	    printf("\nPut \"Enter\" to continue showing: ");
      	    getchar();
      	    clrscr();
        }
      	  frontStud=currentStud;
      	  currentStud=frontStud->next;
      }
        
        frontClass=currentClass;
        currentClass=frontClass->next;
    }
      printf("\nGo to the main page! ");
      getchar();
      mainPage();
}

⌨️ 快捷键说明

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