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

📄 e.bak

📁 c语言版的学生选尅系统
💻 BAK
📖 第 1 页 / 共 2 页
字号:
 while(key!=key_alt_x && key!=key_esc)
  {
   window(1,2,80,25);
     textbackground(BLUE);
     clrscr();
     new1=new2=(struct student *)malloc(sizeof(struct student));
     if(head==NULL)
     head=new1;
     else
    { this1=head;
    while(this1->next!=NULL)
    this1=this1->next;
    this1->next=new1;
    }
    this1=new1;
     printf("\nRecord%d:",n+1);
     printf("\nXing Ming:");
     gets(this1->name);
     printf("\nXue Hao:");
     gets(numstr);
     this1->num=atol(numstr);
     printf("\nNian Ling:");
     gets(this1->age);
     printf("\nXing Bie:");
     gets(this1->sex);
     printf("\nXue Yuan:");
     gets(this1->xibie);
     printf("\nJi Guan:");
     gets(this1->jiguan);
     n++;
     this1->next=NULL;
  printf("Are you sure input :Y/N?");
    if(getch()=='n')
     main();
   else
     new1name();
   }
   main();
} */
   /*listallhanshuyonglaishuchuquanburenyuandejilu*/
   void listall(void)
   {
   int i=0;
   window(1,2,80,25);
textbackground(1);
textcolor(0);
clrscr();
   if(head==NULL)
   {cprintf("\nempty list .\n");return;
   }
   this1=head;

   do
   { cprintf("\nrecord number %d\n",++i);
   cprintf("   name:%s",this1->name);
   cprintf("   number:%ld",this1->num);
   cprintf("   age:%s",this1->age);
   cprintf("   sex:%s",this1->sex);
   cprintf("   xibie:%s",this1->xibie);
   cprintf("   jiguan:%s",this1->jiguan);
   cprintf("   chinese:%6.2f",this1->score.chinese);
   cprintf("   english:%6.2f",this1->score.english);
   cprintf("   math:%6.2f",this1->score.math);
   cprintf("   total:%6.2f",this1->score.total);
   cprintf("   ave:%6.2f\n",this1->score.ave);
   this1=this1->next;
   //this1->next=NULL;
   }while(this1!=NULL);
   getch();
   main();
   }
   //*insert
   struct student *insert(struct student *head,struct student *stud)
   {
   struct student *p0,*p1,*p2;
   p1=head;
   p0=stud;
   if(head==NULL)
   {head=p0;p0->next=NULL;}
   else
   while((p0->num>p1->num) && (p1->next!=NULL))
   {p2=p1;p1=p1->next;}
   if(p0->num<=p1->num)
   {if(head==p1)
   {head=p0;
   p0->next=p1;
   }
   else
   {p2->next=p0;
   p1->next=p1;
   }
   }
   else
   {p1->next=p0;
   p0->next=NULL;
   }
   n=n+1;
   return(head);
   }
    void wfile(void)
   {FILE *fptr;
    char a[10];
   if(n<1)
   {printf("\nCan't write empty list.\n");return;}
  // char a[10];
   cprintf("Please input filename:");
   gets(a);
   if((fptr=fopen(a,"wb"))==NULL)
   printf("\nCant' open file agents.rec\n");
   else
   {this1=head;
 while(this1->next!=NULL)
   {fwrite(this1,sizeof(struct student ),1,fptr);
   this1=this1->next;
   }
  // fwrite(this1,sizeof(struct student ),1,fptr);
   fclose(fptr);
   printf("\nFile of %d records have writen.\n",n);
   }
   getch();
   main();
   }
   //*rfile
   void rfile(void)
   {FILE *fptr;
   char b[10];
   cprintf("Please input filename:");
   gets(b);
   if((fptr=fopen(b,"rb"))==NULL)
   printf("\nCan't open file %s\n",b);
   else
   {n=0;
   head=(struct student *)malloc(sizeof(struct student));
   this1=head;
   fread(this1,sizeof(struct student),1,fptr);
   n++;
   while(1)
   {if(feof(fptr))
   {fclose(fptr);
   this1->next=NULL;printf("\nFile read.Total agents is now %d.\n",n);
getch();   main() ;
   }else{
   this1->next=(struct student *)malloc(sizeof(struct student));
      this1=this1->next;
  fread(this1,sizeof(struct student),1,fptr);
   n++;
   }}  this1->next=NULL;

  //fread(this1,sizeof(struct student),1,fptr);
  //n++;
   fclose(fptr);
   printf("\nFile read.Total agents is now %d.\n",n);
   }
   getch();
   main();
   }
    //*wfile
   /*void wfile(void)
   {char a[10];
   FILE *fptr;
   if(n<1)
   {printf("\nCan't write empty list.\n");return;}
   cprintf("Please input filename:");
   gets(a);
   if((fptr=fopen(a,"wb"))==NULL)
   {cprintf("\nCant' open file ");puts(a);cprintf("\n");
   }
   else
   {fwrite(agent,sizeof(struct student ),n,fptr);
   fclose(fptr);
   printf("\nFile of %d records writen.\n",n);
   }
   getch();
   main();
   }
   //*rfile
   void rfile(void)
   {FILE *fptr;
   char a[10];
   cprintf("Please input filename:");
   gets(a);
   if((fptr=fopen(a,"wb"))==NULL)
   {cprintf("\nCan't open file ");puts(a);
   }
   else
   {while(fread(&agent[n],sizeof(agent[n]),1,fptr)==1)
   n++;
   fclose(fptr);
   printf("\nFile read.Total agents is now %d.\n",n);
   }
   getch();
   main();
   } */
    //*cjlr
   void cjlr(void)
   {struct student *p1;
   long num;  char ddd[5];
   char ccc[5];
   window(1,2,80,25);
   textbackground(BLUE);
   clrscr();
   p1=head;
   printf("input the student' number:");
   scanf("%ld",&num);
   if(head==NULL)
   {
   printf("\nlist null!\n");
   }
   p1=head;
   while(num!=p1->num && p1->next!=NULL)
   {p1=p1->next;}
   if(p1->num==num)
   {printf("chinese:");
   scanf("%f",&p1->score.chinese);
   // gets(ccc);printf("\n");
   // p1->score.chinese=atof(ccc);
   printf("english:");
    scanf("%f",&p1->score.english);
   // gets(numstr);
   //p1->score.english=atof(numstr);
   //getch();
    printf("math:");
   scanf("%s",ddd);
  // gets(ddd);
  p1->score.math=atof(ddd);
   p1->score.total=p1->score.chinese+p1->score.english+p1->score.math;
   p1->score.ave=(p1->score.chinese+p1->score.english+p1->score.math)/3.0;
   }
   getch();
   main();
   }
   //*cjlr
   /*void cjlr(void)
   {struct student *p1;
   long num;  char ddd[4];
   window(1,2,80,25);
   textbackground(BLUE);
   clrscr();
   p1=head;
   printf("input the student' number:");
   scanf("%ld",&num);
   if(head==NULL)
   {
   printf("\nlist null!\n");
   }
   p1=head;
   while(num!=p1->num && p1->next!=NULL)
   {p1=p1->next;}
   if(p1->num==num)
   {printf("chinese:");
    scanf("%f",p1->score.chinese);
    //gets(numstr);
   //p1->score.chinese=atof(numstr);
   //getch();
   printf("english:");
    scanf("%f",p1->score.english);
    //gets(numstr);
   //p1->score.english=atof(numstr);
  // getch();
    printf("math:");
   //scanf("%f",p1->score.math);
   gets(ddd);
   p1->score.math=atof(ddd);
   p1->score.ave=(p1->score.chinese+p1->score.english+p1->score.math)/3.0;
   getch();
   }
   getch();
   main();
   } */
   //*del
   void del()
   {struct student *p1,*p2;
   long num;
    window(1,2,80,25);
   textbackground(BLUE);
   clrscr();
   printf("input the del student' number:");
   scanf("%ld",&num);
   if(head==NULL)
   {
   printf("\nlist null!\n"); exit(1);
   }
   p1=head;
   while(num!=p1->num && p1->next!=NULL)
   {p2=p1;p1=p1->next;
   }
   if(num==p1->num)
   {if(p1==head) head=p1->next;
   else
   p2->next=p1->next;
   printf("the %ld message have del\n",num);
   n=n-1;
   }
   else
   printf("No find %ld!\n",num);
   getch();
   main();
   }
   //
   void cjtj(void)
   {struct student *p;
   for(p=head;p!=NULL;p=p->next)
    { p->score.total=p->score.chinese+p->score.english+p->score.math;
      p->score.ave=p->score.total/3.0;
    }
   }
    //
    void cjpx(void)
    {
     struct student *p,*p1;
     int i,j,t;
     float temp;
     for(i=0;i<n;i++)
     {

	p=head;
	p1=p->next;
	if(p->score.total<p1->score.total)
	  {temp=p->score.total;
	   p->score.total=p1->score.total;
	   p1->score.total=temp;
	  }
	 }
     }
     //
     void cxxs(void)
     { struct student *p;
     char name1[20];
     window(1,2,80,25);
      textbackground(BLUE);
      clrscr();
      printf("shu ru yao cha xun de xue sheng de xing ming:");
      gets(name1);
      for(p=head;p!=NULL;p=p->next)
       {if(strcmp(p->name,name1)==0)

       {printf("xingming:%s\n",p->name);
	printf("xuehao:%ld\n",p->num);
	printf("nianling:%s\n",p->age);
	printf("xingbie:%s\n",p->sex);
	printf("xibie:%s\n",p->xibie);
	printf("jiguan:%s\n",p->jiguan);
       }
      } getch();
   main();
     }
     /*chaxunchengji*/
     void cxcj(void)
     {  struct student *p;
	char name2[20]; int i;
	window(1,2,80,25);
	textbackground(BLUE);
	clrscr();
	printf("shu ru yao cha xu de xue sheng de xingming:");
	gets(name2);
	for(p=head;p!=NULL;p=p->next)
	 {if(strcmp(p->name,name2)==0)
	   {printf("xingming:%s\n",p->name);
	    printf("chinese:%6.2f\n",p->score.chinese);
	    printf("english:%6.2f\n",p->score.english);
	    printf("math:%6.2f\n",p->score.math);
	    printf("total:%6.2f\n",p->score.total);
	    printf("ave:%6.2f\n",p->score.ave);
	    }
	   }getch();
   main();
	   }

/*dayingmugexueshen*/
void list(void)
{  char name3[20];
   int i=0;
   window(1,2,80,25);
   textbackground(BLUE);
   clrscr();
   printf("shu ru yao da ying de xue sheng xingming:");
   gets(name3);
   if(head==NULL)
    { printf("\nempty list.\n");
    return;
    }
   for(this1=head;this1!=NULL;this1=this1->next)
   {
     if(strcmp(this1->name,name3)==0)
     {printf("\nnrecord number %d\n",++i);
      printf("xingmming:%s\n",this1->name);
      printf("xuehao:%ld\n",this1->num);
      printf("nianling:%d\n",this1->age);
      printf("xingbie:%s\n",this1->sex);
      printf("xueyuan:%s\n",this1->xibie);
      printf("jiguan:%s\n",this1->jiguan);
      printf("chinese:%6.2f\n",this1->score.chinese);
      printf("english:%6.2f\n",this1->score.english);
      printf("math:%6.2f\n",this1->score.math);
      printf("total:%6.2f\n",this1->score.total);
      printf("ave:%6.2f\n",this1->score.ave);
      }

    } getch();
   main();
    }



⌨️ 快捷键说明

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