关于c++学生信息管理系统,c学生信息管理系统设计这个很多人还不知道,今天小篇来为大家解答以上的问题,现在让我们一起来看看吧!
c++学生信息管理系统 c学生信息管理系统设计
c++学生信息管理系统 c学生信息管理系统设计
c++学生信息管理系统 c学生信息管理系统设计
1、这个是我以前编的,有些小错误,你参考一下:#include"stdio.h"#include"stdlib.h"#include"malloc.h"#include"string.h"typedef struct stud{long int number;char name[20];int grade;char other[30];char [10];struct stud next;}T;T creat(){T p,q,head;long int number;int grade;char name[20],other[30],[10];head=(T )malloc(sizeof(T));q=head;printf("Please input the data:(num,name,,grade,other,0:end)n");scanf("%ld",&number);fflush(stdin);if(number){gets(name);gets();scanf("%d",&grade);fflush(stdin);gets(other);}while(number){p=(T )malloc(sizeof(T));q->number=number;strcpy(q->name,name);strcpy(q->,);q->grade=grade;strcpy(q->other,other);q->next=p;q=p;scanf("%ld",&number);fflush(stdin);if(number){gets(name);gets();scanf("%d",&grade);fflush(stdin);gets(other);}}q->next=NULL;fflush(stdin);return head;}void print(T head){T p;p=head;if(p)printf("Number name t grade othern");while(p->next){printf("%08ld %-15s%-6s %-8d %sn",p->number,p->name,p->,p->grade,p->other);p=p->next;}printf("nEND!n");}void fprint(T head,FILE fp){T p;p=head;if(p)fprintf(fp,"Number name t grade othern");while(p->next){fprintf(fp,"%08ld %-15s%-6s %-8d %sn",p->number,p->name,p->,p->grade,p->other);p=p->next;}fprintf(fp,"nEND!n");}T range(T head){T p,q,s;int key;printf("Please input the key you want to range:n1.number,2.name,3.,4.grade,5.other.nYour cho:[ ]bb");scanf("%d",&key);fflush(stdin);s=q=head;p=q->next;switch(key){case 1:while(p){if(s->number>p->number) s=p;p=p->next;}if(s!=head){s->next=head;head=s;}for(s=q=head->next;s;s=q=s->next){for(p=q->next;p;p=p->next)if(s->grade>p->grade) s=p;if(s!=q){s->next=q;q=s;}}break;case 2:while(p){if(strcmp(s->name,p->name)>0) s=p;p=p->next;}if(s!=head){s->next=head;head=s;}for(s=q=head->next;s;s=q=s->next){for(p=q->next;p;p=p->next)if(s->grade>p->grade) s=p;if(s!=q){s->next=q;q=s;}}break;case 3:while(p){if(strcmp(s->,p->)>0) s=p;p=p->next;}if(s!=head){s->next=head;head=s;}for(s=q=head->next;s;s=q=s->next){for(p=q->next;p;p=p->next)if(s->grade>p->grade) s=p;if(s!=q){s->next=q;q=s;}}break;case 4:while(p){if(s->grade>p->grade) s=p;p=p->next;}if(s!=head){s->next=head;head=s;}for(s=q=head->next;s;s=q=s->next){for(p=q->next;p;p=p->next)if(s->grade>p->grade) s=p;if(s!=q){s->next=q;q=s;}}break;case 5:while(p){if(strcmp(s->other,p->other)>0) s=p;p=p->next;}if(s!=head){s->next=head;head=s;}for(s=q=head->next;s;s=q=s->next){for(p=q->next;p;p=p->next)if(s->grade>p->grade) s=p;if(s!=q){s->next=q;q=s;}}break;}return head;}T range_1(T head){T p,q,s;s=q=head;p=q->next;while(p){if(s->number>p->number) s=p;p=p->next;}if(s!=head){s->next=head;head=s;}for(s=q=head->next;s;s=q=s->next){for(p=q->next;p;p=p->next)if(s->grade>p->grade) s=p;if(s!=q){s->next=q;q=s;}}return head;}T insert(T head){T p,q,s;s=(T )malloc(sizeof(T));printf("Please input the insert data:(num,name,,grade,other)n");scanf("%ld",&s->number);fflush(stdin);if(s->number==0){printf("ERROR!nPlease input number again.n");scanf("%ld",&s->number);fflush(stdin);}gets(s->name);gets(s->);scanf("%d",&s->grade);fflush(stdin);gets(s->other);q=head;p=q->next;if(q->number>s->number){s->next=head;head=s;}while(q->numbernumber&&p){q=p;p=q->next;}/if(!q){q->next=s;s->next=NULL;}else{s->next=p;q->next=s;}/s->next=p;q->next=s;return head;}T del(T head){T p,q;long int x;int key=2;print(head);printf("Please input the data you want to delete:(num)n");scanf("%ld",&x);fflush(stdin);for(;key==2;){printf("Are you sure?n1.OK.n2.Input new.n3.Exit delete.nYour cho:[ ]bb");scanf("%d",&key);fflush(stdin);if(key==3) return head;if(key==2) scanf("%ld",&x);}q=head;p=q->next;if(q->number==x){head=p;return(head);}while(q&&p->number!=x){q=p;p=q->next;}if(q){q->next=p->next;free(p);}else printf("NOT Found!!!n");return head;}void prt(){printf(" welcome to use!!! tt========================n");printf(" tt Linklist Student n");printf(" tt by czj n");printf(" tt 2008 10 4 n");printf(" tt========================n");}void fprt(FILE p){fprintf(p," welcome to use!!! tt========================n");fprintf(p," tt Linklist Student n");fprintf(p," tt by czj n");fprintf(p," tt 2008 10 4 n");fprintf(p," tt========================n");}void main(){T head=NULL;int key=1;FILE p;prt();head=creat();print(head);printf("1.INSERT.n2.DLETE.n3.CORRECT.n4.RANGE.n0.EXIT.nYour cho[ ]bb");scanf("%d",&key);fflush(stdin);for(;key;){("cls");prt();if(key==1) insert(head);if(key==2||key==3) del(head);if(key==3) insert(head);if(key==4) range(head);print(head);printf("1.INSERT.n2.DELETE.n3.CORRECT.n4.RANGE.n0.EXIT.nYour cho[ ]bb");scanf("%d",&key);fflush(stdin);}if((p=fopen("d:linklist1.dat","w"))==NULL){printf("Can't open the file.n");exit(0);}fprt(p);fprint(head,p);fclose(p);}/一个不用。
2、fflush(stdin);清除缓存。
3、insert中输入有问题,range。
本文到这结束,希望上面文章对大家有所帮助。
版权声明:本文内容由互联。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发 836084111@qq.com 邮箱删除。