学生成绩管理系统

作者在 2011-08-23 12:59:21 发布以下内容

/*  HELLO.C -- Hello, world */

 

 

#include "stdio.h"

#include "conio.h"

 

#define maxsize 70

 

typedef struct stu{

   char name[maxsize];

   int score;

   long stuno;

   struct stu *next;

}*studife;

 

studife p,q,Head=NULL;

 

 

void build()

{  int y,quantity;

   p=Head;

   printf("please input your want amount:");

   scanf("%d",&quantity);

   for(y=0;y<quantity;y++)

 {

    q=(studife)malloc(sizeof(studife));

    if(Head==NULL)

    Head=q;

    printf("\nplease input data:\n");

    scanf("%ld%s%d",&q->stuno,q->name,&q->score);

    q->next=NULL;

    p->next=q;

    p=q;

 }

    printf("\n");

}

 

 

void emptyf()

{  if(Head==NULL)

     printf("The linklist is empty!\n");

   else

     printf("The linklist is not empty.\n");

}

 

 

void find()

{  studife t;

   printf("\n\n\n");

   for(t=Head;t!=NULL;t=t->next)

   printf("%ld  %s  %d\n",t->stuno,t->name,t->score);

   printf("\n\n\n");

}

 

 

void lengh()

{  studife kolo;

   int i;

   i=0;

   for(kolo=Head;kolo!=NULL;kolo=kolo->next)

   i++;

   printf("There is %d people in record.\n",i);

}

 

void deletee()

{  studife p,q;

   int element;

   printf("please input the element you must delete:");

   scanf("%d",&element);

   printf("\n");

   if(Head==NULL)

  {     printf("The linklist is empty!\n");

        exit(0);

   }

   if(Head->stuno==element)

 {

   q=Head;

   Head=Head->next;

   free(q);

   printf("congratulation!it goes success!\n");

 }

   else

 {

   for(p=Head;p->next->stuno!=element&&p->next!=NULL;p=p->next);

   if(p->next==NULL)

   printf("there is not any element whith %d",element);

   else

  {

   q=p->next;

   p->next=p->next->next;

   free(p);

   printf("congratulation!it goes success!\n");

   }

  }

}

 

 

void insert()

{

   studife nanav;

   int y,i;

   printf("please insert you would number:");

   scanf("%d",&y);

   for(i=0;i<y;i++)

 {

   nanav=(studife)malloc(sizeof(studife));

   p->next=nanav;

   printf("\nplease insert the element data:\n");

   scanf("%ld%s%d",&nanav->stuno,nanav->name,&nanav->score);

   nanav->next=NULL;

   p=nanav;

  }

  printf("\nAll the work haved completed\n\n");

}

 

 

void destroy()

{

   studife w,san;

   w=Head;

      while(w!=NULL)

    { san=w->next;

      free(w);

      w=san;

    }

    Head=NULL;

    printf("\n\nThe linklist haved destroy!\n");

   

}

 

 

main()

{   int swito;

 

    while(1)

{

    textbackground(BLACK);

    window(1,1,80,11);

    clrscr();

     textbackground(RED);

    textcolor(WHITE);

    window(8,4,78,11);

    clrscr();

    textbackground(LIGHTBLUE);

    textcolor(YELLOW);

    window(9,5,77,10);

    clrscr();

    gotoxy(5,2);

    cprintf("   ******************************************************");

     gotoxy(5,3);

    cprintf("       1 build        2 find       3 insert      4 lengh");

    gotoxy(5,4);

    cprintf("       5 deletee      6 destroy    7 emptyf      0 exit:");

    gotoxy(5,5);

    cprintf("   ******************************************************");

    printf("\n\n                you can choose a point: ");

    scanf("%d",&swito);

    window(1,12,80,25);

    textbackground(BLACK);

    clrscr();

    switch(swito)

  { case 1:build();  break;

    case 2:find();   break;

    case 3:insert(); break;

    case 4:lengh();  break;

    case 5:deletee();break;

    case 6:destroy();break;

    case 7:emptyf(); break;

    case 0:exit();

    default :printf("you haved make a mistake\n\n\n");

   }

  }

    getch();

}

 

 

源代码 | 阅读 696 次
文章评论,共0条
游客请输入验证码
文章归档
最新评论