学生管理系统——小试牛刀

此代码会有不足之处或者需要改进的地方!请各位不了手下留情!多多提醒我改进的地方。那么有劳各位费一点时间运行一下我的代码!想交流想法的大神或者尬聊的各位多多欢迎评论。

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <windows.h>
#include <conio.h>
//建立结构体
struct Student_n  //学生的自然信息
{
 int iNumber;
 char cName[20];
 char sex[5];
 int old;
 char nation[10];
 Student_n* pNext;
};
//建立结构体
struct Student_p  //学生的选课信息
{
 int iNumber;
 char cName[20];
 int scnumber;
 char scname[20];
 Student_p* pNext;
};
//建立结构体
struct Student_s //学生的成绩
{
 int iNumber;
 char cName[20];
 int scnumber;
 char scname[20];
 int sc;
 Student_s* pNext;
};
//建立空表头
Student_n* head_n()
{
 Student_n* pHead = (Student_n *)malloc(sizeof(Student_n));
 pHead->pNext = NULL;
 return pHead;
}
int iCount_n;  //记节点的个数
//建立链表
void create_n(Student_n* pHead)
{
 Student_n* temp = (Student_n *)malloc(sizeof(Student_n));  //建立可移动的表头
 Student_n* pNew;
 int i = 1;
 iCount_n = 0; 
 printf("开始输入学生基本信息!\n\n"); 
 while(1)
 {
  pNew = (Student_n *)malloc(sizeof(Student_n));
  pNew->pNext = NULL;
  printf("输入第%d个人的信息(输入0终止输入):\n", i);
  printf("学号:");
  scanf("%d", &pNew->iNumber);
  if(pNew->iNumber == 0)
  {
   break;
  }
  printf("姓名:");
  scanf("%s", pNew->cName);
  printf("性别:");
  scanf("%s", pNew->sex);
  printf("年龄:");
  scanf("%d", &pNew->old);
  printf("民族:");
  scanf("%s", pNew->nation);
  if(i == 1)
  {
   pHead->pNext = pNew;
   temp = pNew;
  }
  else
  {
   temp->pNext = pNew;
   temp = temp->pNext;
   temp->pNext = NULL;
  }
  iCount_n++;
  i++;
 }
 free(pNew);
}
//添加基本信息
void insert_n(Student_n* pHead)
{
 int j = 1;
 int i = iCount_n;
 Student_n* ptemp;
 Student_n* p, *temp;  //可移动的添加链表
 Student_n* head = (Student_n *)malloc(sizeof(Student_n));
 while(1)
 {
  temp = (Student_n *)malloc(sizeof(Student_n));
  temp->pNext = NULL;
  printf("添加第%d个人的信息:(输入0终止输入)\n", i + 1);
  printf("学号:");
  scanf("%d", &temp->iNumber);
   if(temp->iNumber == 0)
   {
    break;
   }
  printf("姓名:");
  scanf("%s", temp->cName);
  printf("性别:");
  scanf("%s", temp->sex);
  printf("年龄:");
  scanf("%d", &temp->old);
  printf("民族:");
  scanf("%s", temp->nation);
  if(j == 1)
  {
   head = temp;
   p = temp;
  }
  else
  {
   p->pNext = temp;
   p = p->pNext;
   p->pNext = NULL;
  }
  i++;
  iCount_n++;
 }
 free(temp);
 ptemp = pHead;
 while(ptemp->pNext != NULL)
 {
  ptemp = ptemp->pNext;
 }
 ptemp->pNext = head;
}
//删除基本信息
void Delete_n(Student_n* pHead)
{
 int n = 0;  //输入要删除人的学号
 Student_n* p, *temp;  //负责移动的指针
 Student_n* goal;  //要删除的节点
 printf("请输入要删除人的学号:");
  DeLeTe:
 scanf("%d", &n);
 p = pHead;
 temp = pHead;
 goal = pHead;
 while(n != goal->iNumber)
 {
  p = p->pNext;
  goal = goal->pNext;
  if(goal == NULL)
  {
   printf("无此人!请输入正确的学号...\n");
   goto DeLeTe;
  }
 }
 if(goal->pNext == NULL)
 {
  while(temp->pNext != goal)
  {
   temp = temp->pNext;
  }
  temp->pNext = NULL;
  free(goal);
  iCount_n--;
 }
 else
 {
  p = p->pNext;
  while(temp->pNext != goal)
  {
   temp = temp->pNext;
  }
  temp->pNext = p;
  iCount_n--;
  free(goal);
 }
}
//更改基本信息
void change_n(Student_n* pHead)
{
 int n = 0;  //学号
 char name[20];
 int old;
 Student_n* temp;  //负责移动
 printf("请输入要更改人的学号:");
  change:
 scanf("%d", &n);
 temp = pHead;
 while(n != temp->iNumber)
 {
  temp = temp->pNext;
  if(temp == NULL)
  {
   printf("无此人!请输入正确的学号...\n");
   goto change;
  }
 }
 printf("1,更改姓名\n");
 printf("2,更改年龄\n");
  errorchange:
 scanf("%d", &n);
  if(n == 1)
  {
   printf("请输入新的姓名:");
   scanf("%s", name);
   strcpy(temp->cName, name);
  }
  else if(n == 2)
  {
   printf("请输入新的年龄:");
   scanf("%d", &old);
   temp->old = old;
  }
  else
  {
   printf("输入有误!请重新输入...\n");
   goto errorchange;
  }
}
//存盘
void Fileoutput_n(Student_n* pHead)
{
 pHead = pHead->pNext;
 Student_n* head;  //临时指针负责移动
 head = pHead;
 FILE* p = fopen("nature.dat", "wb");
 if(p == NULL)
 {
  printf("指针为空\n");
  exit(1);
 }
 while(head != NULL)
 {
  fwrite(head, sizeof(Student_n), 1, p);
  head = head->pNext;
 }
 fclose(p);
}
//读盘
void Fileinput_n(Student_n* pHead_n)
{
 iCount_n = 0;
 int i = 1;
 Student_n* head;
 Student_n* temp = (Student_n *)malloc(sizeof(Student_n));
 Student_n pNew;
 head = pHead_n;
 FILE* p = fopen("nature.dat", "rb");
 if(p == NULL)
 {
  printf("文件为空!\n");
  exit(1);
 }
 while(fread(&pNew, sizeof(Student_n), 1, p) == 1)
 {
  temp = (Student_n *)malloc(sizeof(Student_n));
  *temp = pNew;
  head->pNext = temp;
  head = head->pNext;
  head->pNext = NULL;
  iCount_n++;
 }
 fclose(p);
}
//遍历
void traversal_n(Student_n* pHead)
{
 Student_n* temp;  //临时指针负责移动
 temp = pHead;
 int i = 1;
 if(pHead->pNext == NULL)
 {
  printf("链表为空!\n");
  exit(1);
 }
 temp = temp->pNext;
 printf("输出%d个人的信息!\n", iCount_n);
 while(temp != NULL)
 {
  printf("输出第%d个人的信息:\n", i);
  printf("学号:%d\n", temp->iNumber);
  printf("姓名:%s\n", temp->cName);
  printf("性别:%s\n", temp->sex);
  printf("年龄:%d\n", temp->old);
  printf("民族:%s\n", temp->nation);
  temp = temp->pNext;
  i++;
 }
}
int iCount_p;
//建立选课信息的空表头
Student_p* head_p()
{
 Student_p* head = (Student_p *)malloc(sizeof(Student_p));
 head->pNext = NULL;
 return head;
}
//建立选课信息链表
void create_p(Student_p* pHead)
{
 int i = 1;
 iCount_p = 0;
 printf("开始输入学生选课信息\n");
 Student_p* head = pHead;
 Student_p* pNew;
 while(1)
 {
  pNew = (Student_p *)malloc(sizeof(Student_p));
  printf("第%d个人的选课信息(输入0终止输入):\n", i);
  printf("学号:");
  scanf("%d", &pNew->iNumber);
   if(pNew->iNumber == 0)
   {
    break;
   }
  printf("姓名:");
  scanf("%s", pNew->cName);
  printf("课程号:");
  scanf("%d", &pNew->scnumber);
  printf("课程名:");
  scanf("%s", pNew->scname);
  head->pNext = pNew;
  head = head->pNext;
  head->pNext = NULL;
  iCount_p++;
  i++;
 }
}
//添加选课信息
void insert_p(Student_p* pHead)
{
 int j = 1;
 int i = iCount_p;
 Student_p* temp;  //负责在原链表上移动
 Student_p* p, *pNew;  //负责在新的联表上移动
 Student_p* head;
 printf("开始添加学生选课信息:\n");
 while(1)
 {
  pNew = (Student_p *)malloc(sizeof(Student_p));
  printf("添加第%d个人的信息(输入0终止输入):\n", i + 1);
  printf("学号:");
  scanf("%d", &pNew->iNumber);
  if(pNew->iNumber == 0)
  {
   break;
  }
  printf("姓名:");
  scanf("%s", pNew->cName);
  printf("课程号:");
  scanf("%d", &pNew->scnumber);
  printf("课程名:");
  scanf("%s", pNew->scname);
  if(j == 1)
  {
   head = pNew;
   p = pNew;
   head->pNext = NULL;
  }
  else
  {
   head->pNext = pNew;
   head = head->pNext;
   head->pNext = NULL;
  }
  j++;
  i++;
  iCount_p++;
 }
 free(pNew);
 temp = pHead;
 while(temp->pNext != NULL)
 {
  temp = temp->pNext;
 }
 temp->pNext = p;
}
//删除选课信息
void Delete_p(Student_p* pHead)
{
 Student_p* p, *temp, *goal;
 int n = 0;
  error123:
 printf("请输入要删除人的学号:");
 scanf("%d", &n);
 temp = pHead;
 p = pHead;
 goal = pHead;
 while(n != goal->iNumber)
 {
  p = p->pNext;
  goal = goal->pNext;
  if(goal == NULL)
  {
   printf("无此人!请输入正确的学号...\n");
   goto error123;
  }
 }
 if(goal->pNext == NULL)
 {
  while(temp->pNext != goal)
  {
   temp = temp->pNext;
  }
  temp->pNext = NULL;
  free(goal);
  iCount_p--;
 }
 else
 {
  p = p->pNext;
  while(temp->pNext != goal)
  {
   temp = temp->pNext;
  }
  temp->pNext = p;
  free(goal);
  iCount_p--;
 }
}
//更改选课信息
void change_p(Student_p* pHead)
{
 char name[20];  //scname
 int number;  //scnumber
 int n = 0;
 Student_p* goal;
 goal = pHead;
  errorchangepick:
 printf("请输入更改人的学号:");
 scanf("%d", &n);
 while(n != goal->iNumber)
 {
  goal = goal->pNext;
  if(goal == NULL)
  {
   printf("无此人!请输入正确的学号...\n");
   goto errorchangepick;
  }
 }
 printf("1,更改选课信息\n");
 printf("2,更改课程号\n");
 printf("3,更改课程名\n");
  errorchange123:
 scanf("%d", &n);
  if(n == 1)
  {
   system("cls");
   printf("请输入新课程号:");
   scanf("%d", &goal->scnumber);
   printf("请输入新课程名:");
   scanf("%s", goal->scname);
  }
  else if(n == 2)
  {
   system("cls");
   printf("请输入新课程号:");
   scanf("%d", &goal->scnumber);
  }
  else if(n == 3)
  {
   system("cls");
   printf("请输入新课程名:");
   scanf("%s", goal->cName);
  }
  else
  {
   printf("输入有误!请重新输入...\n");
   goto errorchange123;
  }
}
//遍历————选课信息
void traversal_p(Student_p* pHead)
{
 int i = 1;
 Student_p* temp = pHead;
 if(pHead->pNext == NULL)
 {
  printf("链表为空!\n");
  exit(1);
 }
 temp = temp->pNext;
 printf("输出%d个人的选课信息:\n\n", iCount_p);
 while(temp != NULL)
 {
  printf("输出第%d个人的信息:\n", i);
  printf("学号:%d\n", temp->iNumber);
  printf("姓名:%s\n", temp->cName);
  printf("课程号:%d\n", temp->scnumber);
  printf("课程名:%s\n", temp->scname);
  temp = temp->pNext;
  i++;
 }
}
//存盘
void Fileoutput_p(Student_p* pHead)
{
 Student_p* head;
 FILE* p = fopen("pick", "wb");
 head = pHead;
 head = head->pNext;
 if(p == NULL)
 {
  printf("指针为空!\n");
  exit(1);
 }
 while(head != NULL)
 {
  fwrite(head, sizeof(Student_p), 1, p);
  head = head->pNext;
 }
 fclose(p);
}
//读盘
void Fileinput_p(Student_p* pHead)
{
 FILE* p = fopen("pick", "rb");
 Student_p* temp = (Student_p *)malloc(sizeof(Student_p));
 Student_p* head;
 Student_p pNew;
 head = pHead;
 if(p == NULL)
 {
  printf("文件为空!\n");
  exit(1);
 }
 while(fread(&pNew, sizeof(Student_p), 1, p) == 1)
 {
  temp = (Student_p *)malloc(sizeof(Student_p));
  *temp = pNew;
  head->pNext = temp;
  head = head->pNext;
  head->pNext = NULL;
  iCount_p++;
 }
 fclose(p);
}
int iCount_s;
//建立课程成绩的空表头
Student_s* head_s()
{
 Student_s* head = (Student_s *)malloc(sizeof(Student_s));
 head->pNext = NULL;
 return head;
}
//建立课程成绩链表
void create_s(Student_s* pHead)
{
 int i = 1;
 iCount_s = 0;
 printf("开始输入学生选课信息\n");
 Student_s* head = pHead;
 Student_s* pNew;
 while(1)
 {
  pNew = (Student_s *)malloc(sizeof(Student_s));
  printf("第%d个人的成绩(输入0终止输入):\n", i);
  printf("学号:");
  scanf("%d", &pNew->iNumber);
   if(pNew->iNumber == 0)
   {
    break;
   }
  printf("姓名:");
  scanf("%s", pNew->cName);
  printf("课程号:");
  scanf("%d", &pNew->scnumber);
  printf("课程名:");
  scanf("%s", pNew->scname);
  printf("成绩:");
  scanf("%d", &pNew->sc);
  head->pNext = pNew;
  head = head->pNext;
  head->pNext = NULL;
  iCount_s++;
  i++;
 }
}
//添加课程成绩
void insert_s(Student_s* pHead)
{
 int j = 1;
 int i = iCount_s;
 Student_s* temp;  //负责在原链表上移动
 Student_s* p, *pNew;  //负责在新的联表上移动
 Student_s* head;
 printf("开始添加学生成绩:\n");
 while(1)
 {
  pNew = (Student_s *)malloc(sizeof(Student_s));
  printf("添加第%d个人的成绩(输入0终止输入):\n", i + 1);
  printf("学号:");
  scanf("%d", &pNew->iNumber);
  if(pNew->iNumber == 0)
  {
   break;
  }
  printf("姓名:");
  scanf("%s", pNew->cName);
  printf("课程号:");
  scanf("%d", &pNew->scnumber);
  printf("课程名:");
  scanf("%s", pNew->scname);
  printf("成绩:");
  scanf("%d", &pNew->sc);
  if(j == 1)
  {
   head = pNew;
   p = pNew;
   head->pNext = NULL;
  }
  else
  {
   head->pNext = pNew;
   head = head->pNext;
   head->pNext = NULL;
  }
  j++;
  i++;
  iCount_s++;
 }
 free(pNew);
 temp = pHead;
 while(temp->pNext != NULL)
 {
  temp = temp->pNext;
 }
 temp->pNext = p;
}
//删除成绩
void Delete_s(Student_s* pHead)
{
 Student_s* p, *temp, *goal;
 int n = 0;
  error123123:
 printf("请输入要删除人的学号:");
 scanf("%d", &n);
 temp = pHead;
 p = pHead;
 goal = pHead;
 while(n != goal->iNumber)
 {
  p = p->pNext;
  goal = goal->pNext;
  if(goal == NULL)
  {
   printf("无此人!请输入正确的学号...\n");
   goto error123123;
  }
 }
 if(goal->pNext == NULL)
 {
  while(temp->pNext != goal)
  {
   temp = temp->pNext;
  }
  temp->pNext = NULL;
  free(goal);
  iCount_s--;
 }
 else
 {
  p = p->pNext;
  while(temp->pNext != goal)
  {
   temp = temp->pNext;
  }
  temp->pNext = p;
  free(goal);
  iCount_s--;
 }
}
//更改成绩
void change_s(Student_s* pHead)
{
 char name[20];  //scname
 int number;  //scnumber
 int n = 0;
 Student_s* goal;
 goal = pHead;
  errorchangescore:
 printf("请输入更改人的学号:");
 scanf("%d", &n);
 while(n != goal->iNumber)
 {
  goal = goal->pNext;
  if(goal == NULL)
  {
   printf("无此人!请输入正确的学号...\n");
   goto errorchangescore;
  }
 }
 printf("更改课程成绩!\n");
 scanf("%d", &goal->sc);
}
//遍历————选课信息
void traversal_s(Student_s* pHead)
{
 int i = 1;
 Student_s* temp = pHead;
 if(pHead->pNext == NULL)
 {
  printf("链表为空!\n");
  exit(1);
 }
 temp = temp->pNext;
 printf("输出%d个人的课程成绩:\n\n", iCount_s);
 while(temp != NULL)
 {
  printf("输出第%d个人的信息:\n", i);
  printf("学号:%d\n", temp->iNumber);
  printf("姓名:%s\n", temp->cName);
  printf("课程号:%d\n", temp->scnumber);
  printf("课程名:%s\n", temp->scname);
  printf("成绩:%d\n", temp->sc);
  temp = temp->pNext;
  i++;
 }
}
//存盘
void Fileoutput_s(Student_s* pHead)
{
 Student_s* head;
 FILE* p = fopen("score.dat", "wb");
 head = pHead;
 head = head->pNext;
 if(p == NULL)
 {
  printf("指针为空!\n");
  exit(1);
 }
 while(head != NULL)
 {
  fwrite(head, sizeof(Student_s), 1, p);
  head = head->pNext;
 }
 fclose(p);
}
//读盘
void Fileinput_s(Student_s* pHead)
{
 FILE* p = fopen("score.dat", "rb");
 Student_s* temp = (Student_s *)malloc(sizeof(Student_s));
 Student_s* head;
 Student_s pNew;
 head = pHead;
 if(p == NULL)
 {
  printf("文件为空!\n");
  exit(1);
 }
 while(fread(&pNew, sizeof(Student_s), 1, p) == 1)
 {
  temp = (Student_s *)malloc(sizeof(Student_s));
  *temp = pNew;
  head->pNext = temp;
  head = head->pNext;
  head->pNext = NULL;
  iCount_s++;
 }
 fclose(p);
}
//成绩排名
int pp;  //高数排名
void ranking(Student_s* pHead)
{
 pp = 1;
 int i = 0, j = 0;
 int score[50], temp;
 int number[50];
 char name[50][20], cname[20];
 Student_s* head;
 head = pHead;
 head = head->pNext;
 for(i = 0; i < iCount_s; i++)
 {
  score[i] = head->sc;
  number[i] = head->iNumber;
  strcpy(name[i], head->cName);
  head = head->pNext;
 }
 for(i = 0; i < iCount_s; i++)
 {
  for(j = 0; j < iCount_s; j++)
  {
   if(score[j] < score[j + 1])
   {
    temp = score[j + 1];
    score[j + 1] = score[j];
    score[j] = temp;
    temp = number[j + 1];
    number[j + 1] = number[j];
    number[j] = temp;
    strcpy(cname, name[j + 1]);
    strcpy(name[j + 1], name[j]);
    strcpy(name[j], cname);
   }
  }
 }
 for(i = 0; i < iCount_s; i++)
 {
  printf("*******\n");
  printf("排名:%d\n", i + 1);
  printf("学号:%d\n", number[i]);
  printf("姓名:%s\n", name[i]);
  printf("分数:%d\n", score[i]);
 }
}
//挂科
void Fail(Student_s* pHead)
{
 int i = 0;
 Student_s* head;
 head = pHead;
 if(head->pNext == NULL)
 {
  printf("链表为空!\n");
  exit(1);
 }
 head = head->pNext;
 while(head != NULL)
 {
  if(head->sc < 60)
  {
   printf("姓名:%s", head->cName);
   printf("学号:%d", head->iNumber);
   printf("成绩:%d", head->sc);
  }
  else
  i++;
  head = head->pNext;
 }
 if(i == iCount_s)
 printf("无挂科的学生 !\n");
}
//按学号查询
void find(Student_s* pHead)
{
 int n = 0;
 Student_s* head;
 head = pHead;
 if(head->pNext == NULL)
 {
  printf("链表为空!\n");
  exit(1);
 }
  find:
 printf("请输入要查询的学号:");
 scanf("%d", &n);
 head = pHead;
 head = head->pNext;
 while(n != head->iNumber)
 {
  head = head->pNext;
  if(head == NULL)
  {
   printf("无此人!请重新输入...\n");
   goto find;
  }
 }
 printf("姓名:%s\n", head->cName);
 printf("学号:%d\n", head->iNumber);
 printf("分数:%d\n", head->sc);
}
//主函数
int main()
{
 int k = 0;  //输入菜单号码
 Student_n* pHead_n;  //基本信息的表头
 Student_p* pHead_p;  //选课信息的表头
 Student_s* pHead_s;
 pHead_n = head_n();  //基本信息的空表头赋值给pHead_n
 pHead_p = head_p();
 pHead_s = head_s();
 Fileinput_n(pHead_n);
 Fileinput_p(pHead_p);
 Fileinput_s(pHead_s);
 printf("请按任意键开始使用!\n");
 getch();
 while(1)
 {
   one1:
  system("cls");
  printf("1,输入信息\n");
  printf("2,添加信息\n");
  printf("3,删除信息\n");
  printf("4,更改信息\n");
  printf("5,查询信息\n");
  printf("0,退出系统\n");
   error:
  scanf("%d", &k);
  switch(k)
  {
   case 1:
    system("cls");
    printf("1,返回到上一页\n");
    printf("2,输入基本信息\n");
    printf("3,输入选课信息\n");
    printf("4,输入课程成绩\n");
    scanf("%d", &k);
    if(k == 1)
    {
     goto one1;
    }
    else if(k == 2)
    {
     system("cls");
     create_n(pHead_n);
     printf("1,保存并返回上一页!\n");
     printf("2,保存并退出系统\n");
      error1:
     scanf("%d", &k);
      if(k == 1)
      {
       Fileoutput_n(pHead_n);
       goto one1;
      }
      else if(k == 2)
      {
       Fileoutput_n(pHead_n);
       exit(0);
      }
      else
      {
       printf("输入错误!请重新输入...\n");
       goto error1;
      }
    }
    else if(k == 3)
    {
     system("cls");
     create_p(pHead_p);
     printf("1,保存并返回上一页\n");
     printf("2,保存并退出系统\n");
      error12:
     scanf("%d", &k);
      if(k == 1)
      {
       Fileoutput_p(pHead_p);
       goto one1;
      }
      else if(k == 2)
      {
       Fileoutput_p(pHead_p);
       exit(0);
      }
      else
      {
       printf("输入错误!请重新输入...\n");
       goto error12;
      }
    }
    else if(k == 4)
    {
     system("cls");
     create_s(pHead_s);
     printf("1,保存并返回上一页\n");
     printf("2,保存并退出系统\n");
      error14:
     scanf("%d", &k);
      if(k == 1)
      {
       Fileoutput_s(pHead_s);
       goto one1;
      }
      else if(k == 2)
      {
       Fileoutput_s(pHead_s);
       exit(0);
      }
      else
      {
       printf("输入错误!请重新输入...\n");
       goto error14;
      }
    }
    break;
   case 2:
    system("cls");
    printf("1,返回上一页\n");
    printf("2,添加学生基本信息\n");
    printf("3,添加学生选课信息\n");
    printf("4,添加学生课程成绩\n");
    scanf("%d", &k);
    if(k == 1)
    {
     goto one1;
    }
    else if(k == 2)
    {
     system("cls");
     insert_n(pHead_n);
     printf("1,保存并返回上一页\n"); //goto one1
     printf("0,保存并退出系统\n");
      error22:
     scanf("%d", &k);
      if(k == 1)
      {
       Fileoutput_n(pHead_n);
       goto one1;
      }
      else if(k == 0)
      {
       Fileoutput_n(pHead_n);
       exit(0);
      }
      else
      {
       printf("输入有误!请重新输入...\n");
       goto error22;
      }
     }
    else if(k == 3)
    {
     system("cls");
     insert_p(pHead_p);
     printf("1,保存并返回上一页\n"); //goto one1
     printf("0,保存并退出系统\n");
      error23:
     scanf("%d", &k);
      if(k == 1)
      {
       Fileoutput_p(pHead_p);
       goto one1;
      }
      else if(k == 0)
      {
       Fileoutput_p(pHead_p);
       exit(0);
      }
      else
      {
       printf("输入有误!请重新输入...\n");
       goto error23;
      }
    }
    else if(k == 4)
    {
     system("cls");
     insert_s(pHead_s);
     printf("1,保存并返回上一页\n"); //goto one1
     printf("0,保存并退出系统\n");
      error24:
     scanf("%d", &k);
      if(k == 1)
      {
       Fileoutput_s(pHead_s);
       goto one1;
      }
      else if(k == 0)
      {
       Fileoutput_s(pHead_s);
       exit(0);
      }
      else
      {
       printf("输入有误!请重新输入...\n");
       goto error24;
      }
    }
    break;
   case 3:
    system("cls");
    printf("1,返回上一页\n");
    printf("2,删除学生基本信息\n");
    printf("3,删除学生选课信息\n");
    printf("4,删除学生课程成绩\n");
    scanf("%d", &k);
    if(k == 1)
    {
     goto one1;
    }
    else if(k == 2)
    {
     Delete_n(pHead_n);
     printf("删除中...\n");
     Sleep(2000);
     system("cls");
     printf("1,保存并返回上一页\n");
     printf("0,保存并退出系统\n");
      error32:
     scanf("%d", &k);
      if(k == 1)
      {
       Fileoutput_n(pHead_n);
       goto one1;
      }
      else if(k == 0)
      {
       Fileoutput_n(pHead_n);
       exit(0);
      }
      else
      {
       printf("输入有误!请重新输入...\n");
       goto error32;
      }
    }
    else if(k == 3)
    {
     Delete_p(pHead_p);
     printf("删除中...\n");
     Sleep(2000);
     system("cls");
     printf("1,保存并返回上一页\n");
     printf("0,保存并退出系统\n");
      error33:
     scanf("%d", &k);
      if(k == 1)
      {
       Fileoutput_p(pHead_p);
       goto one1;
      }
      else if(k == 0)
      {
       Fileoutput_p(pHead_p);
       exit(0);
      }
      else
      {
       printf("输入有误!请重新输入...\n");
       goto error33;
      }
    }
    else if(k == 4)
    {
     Delete_s(pHead_s);
     printf("删除中...\n");
     Sleep(2000);
     system("cls");
     printf("1,保存并返回上一页\n");
     printf("0,保存并退出系统\n");
      error34:
     scanf("%d", &k);
      if(k == 1)
      {
       Fileoutput_s(pHead_s);
       goto one1;
      }
      else if(k == 0)
      {
       Fileoutput_s(pHead_s);
       exit(0);
      }
      else
      {
       printf("输入有误!请重新输入...\n");
       goto error34;
      }
    }
    break;
   case 4:
    system("cls");
    printf("1,返回上一页\n");
    printf("2,更改学生基本信息\n");
    printf("3,更改学生选课信息\n");
    printf("4,更改学生课程成绩\n");
    scanf("%d", &k);
     if(k == 1)
     {
      goto one1;
     }
     else if(k == 2)
     {
      system("cls");
      change_n(pHead_n);
      printf("1,保存并返回上一页\n");
      printf("0,保存并退出系统\n");
       error42:
      scanf("%d", &k);
       if(k == 1)
       {
        Fileoutput_n(pHead_n);
        goto one1;
       }
       else if(k == 0)
       {
        Fileoutput_n(pHead_n);
        exit(0);
       }
       else
       {
        printf("输入有误!请重新输入...\n");
        goto error42;
       }
     }
     else if(k == 3)
     {
      system("cls");
      change_p(pHead_p);
      printf("1,保存并返回上一页\n");
      printf("0,保存并退出系统\n");
       error43:
      scanf("%d", &k);
       if(k == 1)
       {
        Fileoutput_p(pHead_p);
        goto one1;
       }
       else if(k == 0)
       {
        Fileoutput_p(pHead_p);
        exit(0);
       }
       else
       {
        printf("输入有误!请重新输入...\n");
        goto error43;
       }
     } 
     else if(k == 4)
     {
      system("cls");
      change_s(pHead_s);
      printf("1,保存并返回上一页\n");
      printf("0,保存并退出系统\n");
       error44:
      scanf("%d", &k);
       if(k == 1)
       {
        Fileoutput_s(pHead_s);
        goto one1;
       }
       else if(k == 0)
       {
        Fileoutput_s(pHead_s);
        exit(0);
       }
       else
       {
        printf("输入有误!请重新输入...\n");
        goto error44;
       }
     } 
    break;
   case 5:
     five1:
    system("cls");
    printf("1,返回上一页\n");
    printf("2,查询学生基本信息\n");
    printf("3,查询学生选课信息\n");
    printf("4,查询学生成绩信息\n"); 
    printf("5,排名\n");
    printf("6,查询挂科名单\n");
    printf("7,按学号查询成绩\n");
    printf("0,退出系统\n");
     error51:
    scanf("%d", &k);
     if(k == 1)
     {
      goto one1;
     }
     else if(k == 2)
     {
      system("cls");
      traversal_n(pHead_n);
      printf("1,返回上一页\n");
      printf("0,退出系统\n");
       error52:
      scanf("%d", &k);
       if(k == 1)
       {
        goto five1;
       }
       else if(k == 0)
       {
        exit(0);
       }
       else
       {
        printf("输入有误!请重新输入...\n");
        Sleep(2000);
        goto error52;
       }
     }
     else if(k == 3)
     {
      system("cls");
      traversal_p(pHead_p);
      printf("1,返回上一页\n");
      printf("0,退出系统\n");
       error53:
      scanf("%d", &k);
       if(k == 1)
       {
        goto five1;
       }
       else if(k == 0)
       {
        exit(0);
       }
       else
       {
        printf("输入有误!请重新输入...\n");
        Sleep(2000);
        goto error53;
       }
     }
     else if(k == 4)
     {
      system("cls");
      traversal_s(pHead_s);
      printf("1,返回上一页\n");
      printf("0,退出系统\n");
       error54:
      scanf("%d", &k);
       if(k == 1)
       {
        goto five1;
       }
       else if(k == 0)
       {
        exit(0);
       }
       else
       {
        printf("输入有误!请重新输入...\n");
        Sleep(2000);
        goto error54;
       }
     }
     else if(k == 5)
     {
      system("cls");
      ranking(pHead_s);
      printf("请按任意键继续\n");
      getch();
      system("cls");
      printf("1,返回上一页\n");
      printf("0,退出系统\n");
       error55:
      scanf("%d", &k);
       if(k == 1)
       {
        goto five1;
       }
       else if(k == 0)
       {
        exit(0);
       }
       else
       {
        printf("输入有误!请重新输入...\n");
        Sleep(2000);
        goto error55;
       }
     }
     else if(k == 6)
     {
      system("cls");
      Fail(pHead_s);
      printf("请按任意键继续\n");
      getch();
      system("cls");
      printf("1,返回上一页\n");
      printf("0,退出系统\n");
       error56:
      scanf("%d", &k);
       if(k == 1)
       {
        goto five1;
       }
       else if(k == 0)
       {
        exit(0);
       }
       else
       {
        printf("输入有误!请重新输入...\n");
        Sleep(2000);
        goto error56;
       }
     }
     else if(k == 7)
     {
      system("cls");
      find(pHead_s);
      printf("请按任意键继续\n");
      getch();
      system("cls");
      printf("1,返回上一页\n");
      printf("0,退出系统\n");
       error57:
      scanf("%d", &k);
       if(k == 1)
       {
        goto five1;
       }
       else if(k == 0)
       {
        exit(0);
       }
       else
       {
        printf("输入有误!请重新输入...\n");
        Sleep(2000);
        goto error57;
       }
     }
     else if(k == 0)
     {
      exit(0);
     }
     else
     {
      printf("输入有误!请重新输入...\n");
      goto error51;
     }
    break;
   case 0:
    exit(0);
    break;
   defalut:
    printf("输入有误!请重新输入...\n");
    goto error;
  }
 }
 return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值