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

📄 main.c

📁 关于学生数据管理系统用C编的代码
💻 C
📖 第 1 页 / 共 4 页
字号:
    	  currentClass->student=currentStud->next;
    	  saveFile();
    	  printf("\nDelete the student successfully!\n");
    	  printf("Goto the main page!\n");
    	  getchar();
    	  mainPage();
      }
    	else
      {
      	  frontStud=currentStud;
    	  currentStud=frontStud->next;
    	  flag2=1;
    	  goto sameName;  /*可能有重名的学生*/
      }      
    }
}


/*删除某个班的所有内容*/
    int delClass()
{
      char classID[20];
      char temp='',c='',x='';
    
    continueDel: 
    continueFindClass1:
      clrscr();
      printf("\n\n");
      printf("Please input the number of the class in which you want to delete student: ");
      gets(classID);
      
      if(head==NULL)     /*库中没有数据*/
    {
    	printf("No information!\n\n");
    	printf("Go to the main page (Y/N)? ");
    	temp='';
    	scanf("%c%*c",&temp);
    	if(temp=='Y'||temp=='y')
    	  mainPage();
    	else
    	  exit(-1);
    }
      currentClass=head;
      while(currentClass->next!=NULL&&strcmp(currentClass->ID,classID)!=0) /*遍历链表*/
    {
    	frontClass=currentClass;
    	currentClass=frontClass->next;
    }
      if(currentClass->next==NULL&&strcmp(currentClass->ID,classID)!=0) /*找不到此班*/
    {
    	printf("There is no accordant class!\n\n");
    	printf("Continue to find the class (Y/N)? ");
    	temp='';
    	scanf("%c%*c",&temp);
    	if(temp=='Y'||temp=='y')
    	  goto continueFindClass1;
    	else
          mainPage();
    }
    
    /*找到此班准备删除*/
      printf("\nFound the class--%s!\n",currentClass->ID);
      printf("Do you really want to delete it (Y/N)? \n");
      c=getchar();
      getchar();
      
      if(head==currentClass)  /*此班为数据中的第一个班*/
    {
    	if(c=='Y'||c=='y')
      {
      	  head=currentClass->next;
      	  saveFile();
      	  printf("\nDelete the class successfully!\n");
      	  printf("Go to the main page!");
      	  getchar();
      	  mainPage();
      }
        else
      {
      	  printf("\nContinue to delete classes (Y/N)? ");
      	  scanf("%c%*c",&x);
      	  if(x=='Y'||x=='y')
      	{
      	    readFile();
      	    goto continueDel;
      	}
      	  else
      	    mainPage();
      }
    }
      if(currentClass->next==NULL&&strcmp(currentClass->ID,classID)==0) /*此班为最后一个*/
    {
      	if(c=='Y'||c=='y')
      {
      	  frontClass->next=NULL;
      	  saveFile();
      	  printf("\nDelete the class successfully!\n");
      	  printf("Go to the main page!");
      	  getchar();
      	  mainPage();
      }
        else
      {
      	  printf("\nContinue to delete classes (Y/N)? ");
      	  scanf("%c%*c",&x);
      	  if(x=='Y'||x=='y')
      	{
      	    readFile();
      	    goto continueDel;
      	}
      	  else
      	    mainPage();
      }
    }
      if(currentClass->next!=NULL&&strcmp(currentClass->ID,classID)==0) /*此班在中间*/
    {
    	if(c=='Y'||c=='y')
      {
      	  frontClass->next=currentClass->next;
      	  saveFile();
      	  printf("\nDelete the class successfully!\n");
      	  printf("Go to the main page!");
      	  getchar();
      	  mainPage();
      }
        else
      {
      	  printf("\nContinue to delete classes (Y/N)? ");
      	  scanf("%c%*c",&x);
      	  if(x=='Y'||x=='y')
      	{
      	    readFile();
      	    goto continueDel;
      	}
      	  else
      	    mainPage();
      }
    }
}


/*修改各班学生的基本情况*/
    int modifyStudInfo()
{
      char classID2[20],temp4='';
      char temp2[20];
      
    continueFind3:
      clrscr();
      printf("\n\nPlease input the number of the class you want to modify students' information: ");
      gets(classID2);
      
      if(head==NULL)     /*库中没有数据*/
    {
    	printf("No information!\n\n");
    	printf("Go to the main page (Y/N)? ");
    	temp4='';
    	scanf("%c%*c",&temp4);
    	if(temp4=='Y'||temp4=='y')
    	  mainPage();
    	else
    	  exit(-1);
    }
      currentClass=head;
      while(currentClass->next!=NULL&&strcmp(currentClass->ID,classID2)!=0) /*遍历链表*/
    {
    	frontClass=currentClass;
    	currentClass=frontClass->next;
    }
      if(currentClass->next==NULL&&strcmp(currentClass->ID,classID2)!=0) /*找不到此班*/
    {
    	printf("There is no accordant class!\n\n");
    	printf("Continue to find the class (Y/N)? ");
    	temp4='';
    	scanf("%c%*c",&temp4);
    	if(temp4=='Y'||temp4=='y')
    	  goto continueFind3;
    	else
          mainPage();
    }
    
    /*找到该班,修改同学的情况*/
      for(currentStud=currentClass->student;currentStud!=NULL;)
    {
    	printf("\nThe current student--%s   ID--%s\n",currentStud->name,currentStud->ID);
    	printf("Default ID: %s\tModify to: ",currentStud->ID);
    	gets(temp2);
    	if(strcmp(temp2,"")==0)
      {
      }
        else
      {
      	  strcpy(currentStud->ID,temp2);
      }
    	printf("Default sex: %s\tModify to: ",currentStud->sex);
    	gets(temp2);
    	if(strcmp(temp2,"male")==0)
    	  strcpy(currentStud->sex,"Male");
    	if(strcmp(temp2,"Male")==0)
    	  strcpy(currentStud->sex,"Male");
    	if(strcmp(temp2,"m")==0)
          strcpy(currentStud->sex,"Male");
        if(strcmp(temp2,"M")==0)
          strcpy(currentStud->sex,"Male");
        if(strcmp(temp2,"female")==0)
    	  strcpy(currentStud->sex,"Female");
    	if(strcmp(temp2,"Female")==0)
    	  strcpy(currentStud->sex,"Female");
    	if(strcmp(temp2,"f")==0)
          strcpy(currentStud->sex,"Female");
        if(strcmp(temp2,"F")==0)
          strcpy(currentStud->sex,"Female");
        printf("Default age: %s \tModify to: ",currentStud->age);
        gets(temp2);
        if(strcmp(temp2,"")==0)
      {
      }
        else
      {
      	  strcpy(currentStud->age,temp2);
      }
        printf("Default dormitory: %s\tModify to: ",currentStud->dorm);
        gets(temp2);
        if(strcmp(temp2,"")==0)
      {
      }
        else
      {
      	  strcpy(currentStud->dorm,temp2);
      }
        printf("Default telephone: %s\tModify to: ",currentStud->tel); 
        gets(temp2);
        if(strcmp(temp2,"")==0)
      {
      }
        else
      {
      	  strcpy(currentStud->tel,temp2);
      }
      
        frontStud=currentStud;
        currentStud=frontStud->next;
    }
      
      printf("\nThe current class's students' information have been modified!\n\n");
      printf("Continue to modify students' information in another class (Y/N)? ");
      temp4='';
      scanf("%c%*c",&temp4);
      if(temp4=='Y'||temp4=='y')
    {
    	saveFile();
    	readFile();
    	goto continueFind3;
    }
      else
    {
    	saveFile();
        mainPage();
    }
}


/*修改某个学生的某门成绩的函数*/
    int modifyScore()
{
      char classID[20];
      char studentName[20];
      char temp3='',c2='',c3='';
      char sco[10];
      int flag3=0;
      
    continueFindClass3:
      clrscr();
      printf("\n\n");
      printf("Please input the number of the class in which you want to modify score: ");
      gets(classID);
      
      if(head==NULL)     /*库中没有数据*/
    {
    	printf("No information!\n\n");
    	printf("Go to the main page (Y/N)? ");
    	temp3='';
    	scanf("%c%*c",&temp3);
    	if(temp3=='Y'||temp3=='y')
    	  mainPage();
    	else
    	  exit(-1);
    }
      currentClass=head;
      while(currentClass->next!=NULL&&strcmp(currentClass->ID,classID)!=0) /*遍历链表*/
    {
    	frontClass=currentClass;
    	currentClass=frontClass->next;
    }
      if(currentClass->next==NULL&&strcmp(currentClass->ID,classID)!=0) /*找不到此班*/
    {
    	printf("There is no accordant class!\n\n");
    	printf("Continue to find the class (Y/N)? ");
    	temp3='';
    	scanf("%c%*c",&temp3);
    	if(temp3=='Y'||temp3=='y')
    	  goto continueFindClass3;
    	else
          mainPage();
    }
    
    /*找到该班,准备查找某学生*/
      printf("\nFind the class successfully!\n\n");
    continueFindStud3:
      printf("Please input the name of the student you want to modify scores: ");
      gets(studentName);      
      
      if(currentClass->student==NULL)     /*该班没有学生*/
    {
    	printf("No student in this class!\n\n");
    	printf("Go to the main page (Y/N)? ");
    	temp3='';
    	scanf("%c%*c",&temp3);
    	if(temp3=='Y'||temp3=='y')
    	  mainPage();
    	else
    	  exit(-1);
    }
    
      currentStud=currentClass->student;
      flag3=0;
    sameName3:
      while(currentStud->next!=NULL&&strcmp(currentStud->name,studentName)!=0) /*遍历链表*/
    {
    	frontStud=currentStud;
    	currentStud=frontStud->next;
    }
      if(currentStud->next==NULL&&strcmp(currentStud->name,studentName)!=0) /*找不到这个人*/
    {                                                                  /*或者没有重名的人*/
    	if(flag3==0)
      {
    	  printf("There is no accordant student!\n\n");
    	  printf("Continue to find the student (Y/N)? ");
    	  temp3='';
    	  scanf("%c%*c",&temp3);
    	  if(temp3=='Y'||temp3=='y')
    	    goto continueFindStud3;
    	  else
            mainPage();
      }
        else
      {
      	  printf("\nNo other \"%s\"!\n",studentName);
      	  printf("Go to the main page!\n");
      	  getchar();
      	  mainPage();
      }
    }
    
    /*找到此人,修改成绩*/
      printf("\nFound the student! NAME--%s   ID--%s\n",currentStud->name,currentStud->ID);
      printf("Do you really want to modify his/her scores (Y/N)? \n");
      c2=getchar();
      getchar();     
      if(c2=='Y'||c2=='y')
    {
      	if(currentStud->scores==NULL)
      {
    	  printf("\nSorry, the current student does not have scores!\n");
    	  printf("Please go to the main page to register his/her scores!\n\n");
    	  printf("Go to the main page, input \"1\".\n");
    	  printf("Continue to modify scores in the class, input \"2\".\n");
    	  printf("Find another student in the class who has the same name, input \"3\".\n");
    	  scanf("%c%*c",&c3);
    	  switch(c3)
        {
      	    case '1': mainPage();
      	              break;
      	    case '2': goto continueFindClass3;
      	              break;
      	    case '3': 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

⌨️ 快捷键说明

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