c版的学生选课代码课程设计.docx

上传人:b****2 文档编号:1155265 上传时间:2022-10-18 格式:DOCX 页数:6 大小:15.32KB
下载 相关 举报
c版的学生选课代码课程设计.docx_第1页
第1页 / 共6页
c版的学生选课代码课程设计.docx_第2页
第2页 / 共6页
c版的学生选课代码课程设计.docx_第3页
第3页 / 共6页
c版的学生选课代码课程设计.docx_第4页
第4页 / 共6页
c版的学生选课代码课程设计.docx_第5页
第5页 / 共6页
点击查看更多>>
下载资源
资源描述

c版的学生选课代码课程设计.docx

《c版的学生选课代码课程设计.docx》由会员分享,可在线阅读,更多相关《c版的学生选课代码课程设计.docx(6页珍藏版)》请在冰豆网上搜索。

c版的学生选课代码课程设计.docx

c版的学生选课代码课程设计

#include

#include

#include

#include

#defineLENsizeof(structstudent)

intm;

structstudent

{

  longnum;

  charname[20];

  charaddr[30];

  charxueli[20];

  structstudent*next;

  };

voidprint(structstudent*head)

{

  structstudent*p;

  printf("\nNow,There%drecordsare:

\n",m);

  p=head;

  if(head!

=0)

  do

  {

  printf("%ld\t",p->num);

  printf("%s\t",p->name);

  printf("%s\t",p->addr);

  printf("%s\n",p->xueli);

  p=p->next;

  }while(p!

=0);

  }

voidmain()

{

  intn,w;

  structstudent*head=0;

  structstudent*creat();

  voidadd(structstudent*head);

  structstudent*del(structstudent*head);

  voidsearch(structstudent*head);

  do

  {

  printf("\t\t*******************************************\n");

  printf("\t\t***StudentInformationManagementSystem***\n");

  printf("\t\t********************************************\n");

  printf("\t\t****choose********************\n");

  printf("\t\t****1新建学生链表********************\n");

  printf("\t\t****2Modifydata**************\n");

  printf("\t\t****3Searchbypeople.xueliandnum****\n");

  printf("\t\t****4Browsedata*****************\n");

  printf("\t\t****5adddata************\n");

  printf("\t\t****6Exit*************\n");

  printf("\t\t******************************************\n");

  printf("\t\t*******************************************\n");

  printf("chooseyournumber(1-6):

[]\b\b");

  do

  {

  scanf("%d",&n);

  if(n>6||n<1)

  {

    w=1;

    printf("Error,pleaseinputagain(1-6):

");

    }

  elsew=0;

  }while(w==1);

  switch(n)

  {

  case1:

head=creat();break;

  case2:

del(head);break;

  case3:

search(head);break;

  case4:

print(head);break;

  case5:

add(head);break;

  case6:

exit(0);

  }

  }while(n!

=6);

}

structstudent*creat()

{

  structstudent*head;

  structstudent*p1,*p2;

  m=0;

  p1=p2=(structstudent*)malloc(LEN);

  printf("Pleaseinputnumber:

");

  scanf("%ld",&p1->num);

  printf("Pleaseinputname:

");

  scanf("%s",p1->name);

  printf("address:

");

  scanf("%s",p1->addr);

  printf("xueli:

");

  scanf("%s",p1->xueli);

  while(p1->num!

=0)

  {

  m=m+1;

  if(m==1)head=p1;

  elsep2->next=p1;

  p2=p1;

  p1=(structstudent*)malloc(LEN);

  printf("number:

");

  scanf("%ld",&p1->num);

  printf("name:

");

  scanf("%s",p1->name);

  printf("address:

");

  scanf("%s",p1->addr);

  printf("xueli:

");

  scanf("%s",p1->xueli);

  }

  p2->next=0;

  print(head);

  return(head);

  }

structstudent*del(structstudent*head)

{

  longnum;

  structstudent*p1,*p2;

  if(head==0)

  {

  printf("\nlistnull\n");

  exit(0);

  }

  p1=head;

  printf("Whichnumberdoyouwantdel:

");

  scanf("%ld",&num);

  while(num!

=p1->num&&p1->next!

=0)

    {

    p2=p1;

    p1=p1->next;

    }

  if(num==p1->num)

    {

    if(p1==head)head=p1->next;

    elsep2->next=p1->next;

    printf("delete:

%ld\n",num);

    m=m-1;

    }

    elseprintf("%ldnotbeenfound!

\n",num);

    print(head);

    return(head);

    }

void  add(structstudent*head)

{

  structstudent*p0,*p1,*p2;

  p0=(structstudent*)malloc(LEN);

  printf("number:

");

  scanf("%ld",&p0->num);

  printf("name:

");

  scanf("%s",p0->name);

  printf("address:

");

  scanf("%s",p0->addr);

  printf("xueli:

");

  scanf("%s",p0->xueli);

  p1=head;

  if(head==0)

  {

  head=p0;

  p0->next=0;

  }

  else

  {

    while((p0->num>p1->num)&&(p1->next!

=0))

    {

    p2=p1;

    p1=p1->next;

    }

    if(p0->num<=p1->num)

    {

    if(head==p1)head=p0;

    elsep2->next=p0;

    p0->next=p1;

    }

  else

    {

    p1->next=p0;

    p0->next=0;

    }

  }

  m=m+1;

  print(head);

  }

voidsearch(structstudent*head)

{

  intn,w;

  voidname(structstudent*head);

  voidnumber(structstudent*head);

  voidxueli(structstudent*head);

  printf("*****7usenametosearch****\n");

  printf("*****8usenumbertosearch****\n");

  printf("*****9usexuelitosearch****\n");

  printf("chooseyournumber[]\b\b");

  do

  {

  scanf("%d",&n);

  if(n>9||n<7)

    {

    w=1;

    printf("error,pleaseinputagain:

");

    }

    elsew=0;

  }while(w==1);

switch(n)

  {

  case7:

name(head);break;

  case8:

number(head);break;

  case9:

xueli(head);break;

  }

  }

voidname(structstudent*head)

{

  charnam[20];

  intw;

  structstudent*p1;

  printf("Pleaseinputname:

");

  scanf("%s",nam);

  if(head==0)

  {

  printf("\nlistnull\n");

  exit(0);

  }

  p1=head;

  while(strcmp(nam,p1->name)!

=0&&p1->next!

=0)

  {

  p1=p1->next;

  w=0;

  }

  if(strcmp(nam,p1->name)==0)

  {

  printf("%ld\t%s\t%s\t%s\n",p1->num,p1->name,p1->addr,p1->xueli);

  w=1;

  }

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1