收藏 分享(赏)

学生选课系统.doc

上传人:kpmy5893 文档编号:9055122 上传时间:2019-07-22 格式:DOC 页数:13 大小:16.13KB
下载 相关 举报
学生选课系统.doc_第1页
第1页 / 共13页
学生选课系统.doc_第2页
第2页 / 共13页
学生选课系统.doc_第3页
第3页 / 共13页
学生选课系统.doc_第4页
第4页 / 共13页
学生选课系统.doc_第5页
第5页 / 共13页
点击查看更多>>
资源描述

1、#include#include#includetypedef struct subjectsint num1; /char name120; /char kind10; /int stime; /int ttime; /int etime; /int score; /int term; /int yixuan_peo; /int max_peo; /struct subjects *next;SUB;typedef struct studentslong int num2; /char name220; /int yixuan_num50; /int yixuan_shu; /struct

2、students *next;students;SUB *head1;students *head2;int i;void keyboardc()/()SUB *p1,*p2;void intoc();int N1;N1=0;p1=p2=(SUB*)malloc(sizeof(SUB);printf(“ n“);scanf(“%d %s %s %d %d %d %d %d %d %d“,head1=NULL;while(p1-num1!=0)N1=N1+1;if(N1=1)head1=p1;else p2-next=p1;p2=p1;p1=(SUB * )malloc(sizeof(SUB);

3、scanf(“%d %s %s %d %d %d %d %d %d %d“,p2-next=NULL;intoc();void keyboards()/students *p1,*p2;void intos();int N2=0;p1=p2=(students *)malloc(sizeof(students);printf(“tn“);scanf(“%d%s“,p1-yixuan_shu=0;for(i=0;iyixuan_numi=0;head2=NULL;while(p1-num2!=0)N2=N2+1;if(N2=1)head2=p1;else p2-next=p1;p2=p1;p1=

4、(students * )malloc(sizeof(students);scanf(“%d%s“,p1-yixuan_shu=0;for(i=0;iyixuan_numi=0;p2-next=NULL;intos();void filein()/FILE * fp;SUB *p1,*p2;int n1=0;char filepath20;printf(“:“);getchar();gets(filepath);if(fp=fopen(filepath,“r“)=NULL)printf(“%s!n“,filepath);exit(0);p1=p2=(SUB*)malloc(sizeof(SUB

5、);fscanf(fp,“%d %s %s %d %d %d %d %d %d %d“,head1=NULL;while(!feof(fp)n1=n1+1;if(n1=1)head1=p1;else p2-next=p1;p2=p1;p1=(SUB* )malloc(sizeof(SUB);fscanf(fp,“%d %s %s %d %d %d %d %d %d %d“,p2-next=NULL;fclose(fp);void fileins()/FILE *fp;students *p1,*p2;char filepath20;int n2=0;printf(“:“);getchar();

6、gets(filepath);if(fp=fopen(filepath,“r“)=NULL)printf(“%s!n“,filepath);exit(0);p1=p2=(students*)malloc(sizeof(students);fread(p1,sizeof(students),1,fp);head2=NULL;while(!feof(fp)n2=n2+1;if(n2=1)head2=p1;else p2-next=p1;p2=p1;p1=(students * )malloc(sizeof(students);fread(p1,sizeof(students),1,fp);p2-n

7、ext=NULL;fclose(fp);void prin() /SUB *ptr;filein();if(head1=NULL)printf(“nnt*NO RECORDS!*n“);printf(“ n“);for(ptr=head1;ptr!=NULL;ptr=ptr-next)printf(“%5d%12s%9s%9d%9d%11d%11d%7d%8d%8dn“,ptr-num1,ptr-name1,ptr-kind,ptr-stime,ptr-ttime,ptr-etime,ptr-score,ptr-term,ptr-yixuan_peo,ptr-max_peo);void inp

8、ut()/int i;printf(“tttn“);printf(“1.n“);printf(“2.n“);printf(“3.n“);printf(“(13):n“);scanf(“%d“,switch(i)case(1):filein();printf(“n“);break;case(2):keyboardc();break;case(3):break;default:printf(“!“);void inputs()/int i;printf(“tttn“);printf(“1.n“);printf(“2.n“);printf(“3.n“);printf(“(13):n“);scanf(

9、“%d“,switch(i)case(1):fileins();printf(“n“);break;case(2):keyboards();break;case(3):break;default:printf(“);void search() /SUB *ptr;int a,num;int t=1;char type10;students *ptr1;L1: printf(“nntt*n“);printf(“nttt1-n“);printf(“nttt2-n“);printf(“nttt3-n“);printf(“nttt4-n“);printf(“nntt*n“);printf(“nnCho

10、ose your number(1-4): bb“);scanf(“%d“,switch(a)case 1:printf(“:“);scanf(“%s“,type);printf(“ n“);for(ptr=head1;ptr!=NULL;ptr=ptr-next)if(strcmp(type,ptr-kind)=0)printf(“%5d%12s%9s%9d%9d%11d%11d%7d%8d%8dn“,ptr-num1,ptr-name1,ptr-kind,ptr-stime,ptr-ttime,ptr-etime,ptr-score,ptr-term,ptr-yixuan_peo,ptr-

11、max_peo);t=0;if(t=1) printf(“tn!n“);goto L1;case 2:printf(“:“);scanf(“%d“,printf(“ n“);for(ptr=head1;ptr!=NULL;ptr=ptr-next)if(ptr-score=num)printf(“%5d%12s%9s%9d%9d%11d%11d%7d%8d%8dn“,ptr-num1,ptr-name1,ptr-kind,ptr-stime,ptr-ttime,ptr-etime,ptr-score,ptr-term,ptr-yixuan_peo,ptr-max_peo);t=0;if(t=1

12、) printf(“tn!n“);goto L1;case 3:printf(“:“);scanf(“%d“,printf(“ n“);for(ptr1=head2;ptr1!=NULL;ptr1=ptr1-next) if(ptr1-num2=num)printf(“%5d%12s%8dn“,ptr1-num2,ptr1-name2,ptr1-yixuan_shu);t=0;if(t=1) printf(“nt!n“);goto L1;case 4:break;void myInsert(SUB* subj) /SUB *ptr,*ptr2;ptr=subj;if(head1=NULL)he

13、ad1=ptr;head1-next=NULL;elsefor(ptr2=head1;ptr2;ptr2=ptr2-next)if(ptr2-next=NULL)ptr2-next=subj;subj-next=NULL;break;void insert()/SUB *ptr,*subj,*a;int size=sizeof(SUB);char ch,ch1;while(ch!=0)subj=(SUB *)malloc(size);ptr=subj;printf(“:n“);printf(“ntt:“);scanf(“%d“,printf(“ntt:“);scanf(“%s“,printf(

14、“ntt:“);scanf(“%s“,printf(“ntt:“);scanf(“%d“,printf(“ntt:“);scanf(“%d“,printf(“ntt:“);scanf(“%d“,printf(“ntt:“);scanf(“%d“,printf(“ntt:“);scanf(“%d“,printf(“ntt:“);scanf(“%d“,printf(“ntt:“);scanf(“%d“,myInsert(subj);printf(“ n“);for(a=head1;a!=NULL;a=a-next)printf(“%5d%12s%9s%9d%9d%11d%11d%7d%8d%8dn

15、“,a-num1,a-name1,a-kind,a-stime,a-ttime,a-etime,a-score,a-term,a-yixuan_peo,a-max_peo);printf(“nn“);printf(“n 0: bb“);ch1=getchar(); /CH1subj-termCHCH1ch=getchar();void del() /SUB *p1,*p2;int num;printf(“:“);scanf(“%d“,if(head1=NULL)printf(“n,!n“);goto end;p1=head1;while(num!=p1-num1 p1=p1-next;if(n

16、um=p1-num1)if(p1=head1) head1=p1-next;free(p1);else p2-next=p1-next;free(p1);printf(“!n“);else printf(“!n“);end:;void elect()/ char c;students *s;SUB * p;int n1,n2;printf(“:n“);scanf(“%d“,s=head2;while(s-num2)!=n1)if(s=NULL) printf(“n“);goto end;L4: printf(“:n“);scanf(“%d“,p=head1;while(p-num1)!=n2)

17、if(p=NULL) printf(“n“);goto end;if(p-yixuan_peo)=(p-max_peo) printf(“n“);goto end;for(i=0;s-yixuan_numi!=0;i+);s-yixuan_numi=n2;(s-yixuan_shu)+;(p-yixuan_peo)+;printf(“n“);printf(“(y/n)n“);getchar();c=getchar();if(c=y)goto L4;end:;void hcheck()/SUB* p0;students * p;int num2,total=0;printf(“:n“);scan

18、f(“%d“,p=head2;while(p-num2)!=num2) if(p=NULL)printf(“,:n“);goto end;printf(“:n“);if(p-yixuan_num0)=0)printf(“!n“);goto end;for(i=0;(p-yixuan_numi)!=0;i+)printf(“%dn“,p-yixuan_numi);p0=head1;while(p0-num1)!=(p-yixuan_numi) p0=p0-next;total=total+p0-score;printf(“:%dn“,total);printf(“:%dn“,p-yixuan_s

19、hu);end:;void back()/ SUB *p1;char c;students *p2;int num1,num2,j;printf(“:n“);scanf(“%d“,p2=head2;while(p2-num2)!=num2) if(p2=NULL)printf(“n“);goto end;L5: printf(“:n“);scanf(“%d“,p1=head1;while(p1-num1!=num1) p1=p1-next;for(i=0;p2-yixuan_numi!=num1;i+);for(j=i;p2-yixuan_numj!=0;j+) p2-yixuan_numj=

20、p2-yixuan_numj+1;p2-yixuan_num-j=0;p2-yixuan_shu-;(p1-yixuan_peo)-;printf(“!n“);printf(“(y/n)n“);getchar();c=getchar();if(c=y)goto L5;end:;void intoc()/FILE * fp;SUB * p;char filepath30;printf(“:“);getchar();gets(filepath);if(fp=fopen(filepath,“w“)=NULL)printf(“n!“);exit(0);p=head1;while(p!=NULL)fpr

21、intf(fp,“%d %s %s %d %d %d %d %d %d %dn“,p-num1,p-name1,p-kind,p-stime,p-ttime,p-etime,p-score,p-term,p-yixuan_peo,p-max_peo);p=p-next;fclose(fp);printf(“%s!n“,filepath);void intos()/FILE * fp;students * p;char filepath30;printf(“:“);getchar();gets(filepath);if(fp=fopen(filepath,“w“)=NULL)printf(“n!

22、“);exit(0);p=head2;while(p!=NULL)fwrite(p,sizeof(students),1,fp);p=p-next;fclose(fp);printf(“%s!n“,filepath);void into()/int i;printf(“1.n“);printf(“2.n“);printf(“3.n“);printf(“(13)n“);scanf(“%d“,switch(i)case(1):intoc();break;case(2):intos();break;case(3):break;void Mangers()/void Students();int n,

23、flag=0,i=3,w=1;char s8;char password7=“12345“;doprintf(“nnEnter password:“);scanf(“%s“,s);if(strcmp(s,password)=0) /flag=1;break;elseprintf(“nnError! You only have %d times! Enter again:n“,i-1);i-;while(i0);if(flag=0)printf(“you have Enter 3 times!“); /3exit(0); /doprintf(“nntt*nn“);printf(“tttt1-n“

24、);printf(“tttt2-n“);printf(“tttt3-n“);printf(“tttt4-n“);printf(“tttt5-“);printf(“nntt*n“);printf(“Chiose your number(1-5): bb“);scanf(“%d“,switch(n)case 1:inputs();break;case 2:input();break;case 3:insert();intoc();break;case 4:del();intoc();break;case 5:w=0;break;default:printf(“n:“);while(w=1);int

25、 x;start:printf(“nttt-!n“);printf(“:n“);printf(“1.n“);printf(“2.n“);printf(“3.n“);scanf(“%d“,if(x3)printf(“,!n“);goto start;switch(x)case 1:Mangers() ;break;case 2:Students();break;case 3:printf(“!nn!n“);break;void Students()/int n,w=1;doprintf(“nntt*nn“);printf(“tttt1-n“);printf(“tttt2-n“);printf(“

26、tttt3-n“);printf(“tttt4-n“);printf(“tttt5-n“);printf(“tttt6-n“);printf(“tttt7-n“);printf(“tttt8-n“);printf(“nntt*n“);printf(“Chiose your number(1-8): bb“);scanf(“%d“,switch(n)case 1:inputs();break;case 2:prin();break;case 3:search();break;case 4:elect();break;case 5:hcheck();break;case 6:back();brea

27、k;case 7:into();break;case 8:w=0;break;default:printf(“n:“);while(w=1);int y;start:printf(“nttt-!n“);printf(“:n“);printf(“1.n“);printf(“2.n“);printf(“3.n“);scanf(“%d“,if(y3)printf(“,!n“);goto start;switch(y)case 1:Mangers() ;break;case 2:Students();break;case 3:printf(“!nn!n“);break;int main()/int i;start:printf(“nttt-!n“);printf(“:n“);printf(“1.n“);printf(“2.n“);printf(“3.n“);scanf(“%d“,if(i3)printf(“,!n“);goto start;switch(i)case 1:Mangers() ;break;case 2:Students();break;case 3:printf(“!nn!n“);break;return(0);

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

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报