资源描述:
《基于c学生档案管理系统》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、#include#include#include#defineNULL0#defineLEN_ssizeof(structstudent)#defineLEN_csizeof(structcourse)structstudent{charstudent_ID[10];charname[10];chartelephone[12];structstudent*next;};structcourse{charstudent_ID[10];charcourse_ID[10];intscore;structcourse*next;
2、};intscount=0,ccount=0;structstudent*head_s=NULL;structcourse*head_c=NULL;structcourse*add_c(){charstudent_ID[10];charcourse_ID[10];intscore;charcho;structcourse*p1,*p2,*p;do{printf("inputdata:student_ID,course_ID,score");scanf("%s%s%d",student_ID,course_ID,&score);p1=p2=(structcourse*)mal
3、loc(LEN_c);strcpy(p2->student_ID,student_ID);strcpy(p2->course_ID,course_ID);p2->score=score;p2->next=NULL;p1=head_c;if(head_c==NULL){head_c=p2;p2->next=NULL;}else{while((strcmp(p2->student_ID,p1->student_ID)>0)&&(p1->next!=NULL)){p=p1;/*使p指向刚才p1指向的结点*/p1=p1->next;}/*p1后移一个结点*/if(strcmp(p2->
4、student_ID,p1->student_ID)<0){if(head_c==p1)head_c=p2;/*插到原来第一个结点之前*/elsep->next=p2;/*插到p指向的结点之后*/p2->next=p1;}else{p1->next=p2;p2->next=NULL;}}ccount++;getchar();printf("Preaseanykeytocontinue:");printf("按N/n退出");scanf("%c",&cho);}while(cho!='n'&&cho!='N');returnhead_c;}structstudent*add_
5、s(){charstudent_ID[10];charname[10];chartelephone[12];charcho;structstudent*p1,*p2,*p;do{printf("inputdata:student_ID,name,telephone");scanf("%s%s%s",student_ID,name,telephone);p1=p2=(structstudent*)malloc(LEN_s);strcpy(p2->student_ID,student_ID);strcpy(p2->name,name);strcpy(p2->telephone,
6、telephone);p2->next=NULL;p1=head_s;if(head_s==NULL){head_s=p2;p2->next=NULL;}else{while((strcmp(p2->student_ID,p1->student_ID)>0)&&(p1->next!=NULL)){p=p1;/*使p指向刚才p1指向的结点*/p1=p1->next;}/*p1后移一个结点*/if(strcmp(p2->student_ID,p1->student_ID)<0){if(head_s==p1)head_s=p2;/*插到原来第一个结点之前*/elsep->next=p
7、2;/*插到p指向的结点之后*/p2->next=p1;}else{p1->next=p2;p2->next=NULL;}}scount++;getchar();printf("Preaseanykeytocontinue:");printf("按N/n退出");scanf("%c",&cho);}while(cho!='n'&&cho!='N');returnhead_s;}voidprint_s(){structstudent*p;printf("Now,These%drecor