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

📄 newwintc.c

📁 学生信息管理系统,用链表实现,包含删除,增加,查询,保存到文件等功能
💻 C
📖 第 1 页 / 共 2 页
字号:
printf("〓〓\n");
printf("\n");
printf("\n\t\t\t  Ⅰ按数学成绩排序\n");
printf("\n");
printf("\n\t\t\t  Ⅱ按英语成绩排序\n");
printf("\n");
printf("\n\t\t\t  Ⅲ按体育成绩排序\n");
printf("\n");
printf("\n\t\t\t  Ⅳ按平均分排序\n");
printf("\n");
printf("                                                                            〓〓\n");
printf("〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓\n");
switch(getch())
{
 case '1':clrscr();
          if((fp=fopen("record.txt","rb"))==NULL)printf("数据文件不存在!");
          else
             { /*取表头!!*/
                head=s;

                while(fread(s,sizeof(struct stu_info),1,fp)==1)
                {
                  f=s;
                  p=(struct stu_info *)malloc(sizeof(struct stu_info));
                  s->next=p;
                  s=p;

                 }
                 free(s);
                 f->next=NULL;
                 fclose(fp);

             }
      /*排序*/

      newhead=newnode;

      while(head!=NULL)
      {
            front=head;
            i=head;
            t=head;

            for(i=head;i->next!=NULL;i=i->next)
            {
                if(t->mark[0].fen>(i->next)->mark[0].fen)
                {


                    front=i;
                    t=i->next;
                 }

              }


              n++;
              if(n==1){
                newhead=t;
                newnode=newhead;
              }
              else{
                newnode->next=t;
                newnode=newnode->next;
              }


              if(t==head)
                    head=head->next;
              else
                front->next=t->next;


        }

         if((fp=fopen("record.txt","wb"))==NULL)printf("数据文件不存在!");
         else
             {       while(newhead!=NULL)
                {
                     if(fwrite(newhead,sizeof(struct stu_info),1,fp)==1)
                     newhead=newhead->next;
                }

             }
          fclose(fp);
          Print();
         break;
 case '2':clrscr();
          if((fp=fopen("record.txt","rb"))==NULL)printf("数据文件不存在!");
          else
             { /*取表头!!*/
                head=s;

                while(fread(s,sizeof(struct stu_info),1,fp)==1)
                {
                  f=s;
                  p=(struct stu_info *)malloc(sizeof(struct stu_info));
                  s->next=p;
                  s=p;

                 }
                 free(s);
                 f->next=NULL;
                 fclose(fp);

             }
      /*排序*/

      newhead=newnode;

      while(head!=NULL)
      {
            front=head;
            i=head;
            t=head;

            for(i=head;i->next!=NULL;i=i->next)
            {
                if(t->mark[1].fen>(i->next)->mark[1].fen)
                {


                    front=i;
                    t=i->next;
                 }

              }


              n++;
              if(n==1){
                newhead=t;
                newnode=newhead;
              }
              else{
                newnode->next=t;
                newnode=newnode->next;
              }


              if(t==head)
                    head=head->next;
              else
                front->next=t->next;


        }

         if((fp=fopen("record.txt","wb"))==NULL)printf("数据文件不存在!");
         else
             {       while(newhead!=NULL)
                {
                     if(fwrite(newhead,sizeof(struct stu_info),1,fp)==1)
                     newhead=newhead->next;
                }

             }
          fclose(fp);
          Print();
         break;

 case '3':clrscr();
          if((fp=fopen("record.txt","rb"))==NULL)printf("数据文件不存在!");
          else
             { /*取表头!!*/
                head=s;

                while(fread(s,sizeof(struct stu_info),1,fp)==1)
                {
                  f=s;
                  p=(struct stu_info *)malloc(sizeof(struct stu_info));
                  s->next=p;
                  s=p;

                 }
                 free(s);
                 f->next=NULL;
                 fclose(fp);

             }
      /*排序*/

      newhead=newnode;

      while(head!=NULL)
      {
            front=head;
            i=head;
            t=head;

            for(i=head;i->next!=NULL;i=i->next)
            {
                if(t->mark[2].fen>(i->next)->mark[2].fen)
                {


                    front=i;
                    t=i->next;
                 }

              }


              n++;
              if(n==1){
                newhead=t;
                newnode=newhead;
              }
              else{
                newnode->next=t;
                newnode=newnode->next;
              }


              if(t==head)
                    head=head->next;
              else
                front->next=t->next;


        }

         if((fp=fopen("record.txt","wb"))==NULL)printf("数据文件不存在!");
         else
             {       while(newhead!=NULL)
                {
                     if(fwrite(newhead,sizeof(struct stu_info),1,fp)==1)
                     newhead=newhead->next;
                }

             }
          fclose(fp);
          Print();
         break;

 case '4':clrscr();
          if((fp=fopen("record.txt","rb"))==NULL)printf("数据文件不存在!");
          else
             { /*取表头!!*/
                head=s;

                while(fread(s,sizeof(struct stu_info),1,fp)==1)
                {
                  f=s;
                  p=(struct stu_info *)malloc(sizeof(struct stu_info));
                  s->next=p;
                  s=p;

                 }
                 free(s);
                 f->next=NULL;
                 fclose(fp);

             }
      /*排序*/

      newhead=newnode;

      while(head!=NULL)
      {
            front=head;
            i=head;
            t=head;

            for(i=head;i->next!=NULL;i=i->next)
            {
                if(t->mark[3].fen>(i->next)->mark[3].fen)
                {


                    front=i;
                    t=i->next;
                 }

              }


              n++;
              if(n==1){
                newhead=t;
                newnode=newhead;
              }
              else{
                newnode->next=t;
                newnode=newnode->next;
              }


              if(t==head)
                    head=head->next;
              else
                front->next=t->next;


        }

         if((fp=fopen("record.txt","wb"))==NULL)printf("数据文件不存在!");
         else
             {       while(newhead!=NULL)
                {
                     if(fwrite(newhead,sizeof(struct stu_info),1,fp)==1)
                     newhead=newhead->next;
                }

             }
          fclose(fp);
          Print();
         break;
}

}







/*程序结束界面*/
void Bye()
{
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");
printf("\n");
printf("\n");
printf("\t本程序由软二051 葛飞制作\n");
printf("\n");
printf("\n");
printf("\t程序的完成与老师们的细心指导密不可分\n");
printf("\n");
printf("\n");
printf("\t感谢老师们的帮助和支持!\n");
printf("\n");
printf("\n");
printf("                                                        制作时间 07.09.19\n");
printf("\n");
printf("\n");
printf("\n");
printf("\t                             谢谢您的使用!\n");
printf("\n");
printf("\n");
printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");
getch();

}
void Menu()
{

clrscr();
printf("\n");
printf("\n"); printf("\n");printf("\n");
printf("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆学生数据管理系统☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n");
printf("\n");
printf("\n");
printf("\t\t\t  1.插入学生信息\n");
printf("\n");
printf("\t\t\t  2.排序\n");
printf("\n");
printf("\t\t\t  3.显示学生信息\n");
printf("\n");
printf("\t\t\t  4.删除学生信息\n");
printf("\n");
printf("\t\t\t  5.查询学生信息\n");
printf("\n");
printf("\t\t\t  6.退出系统\n");
printf("\n");

/* 输出菜单信息 */
/* 选择菜单项 */
  switch(getch())
  {
  /* 插入项 书写完毕*/
  case '1':Insert();Menu();break;
  /* 排序项 未书写*/
  case '2': Sort();Menu(); break;
  /* 显示项 书写完毕*/
  case '3': Print();Menu();break;
  /* 删除项 有问题*/
  case '4': Del();Menu();break;
  /* 查询项 书写完毕*/
  case '5': Search();Menu();break;
  /* 退出项 书写完毕*/
  case '6': Bye();
             break;
  default : clrscr();printf("\n\n请在1-6之间进行选择...");sleep(1);Menu();break;
  } 


}


⌨️ 快捷键说明

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