我是开网吧的,目前使用的是摇钱树网吧计费管理软件,很不错的,推荐你也试试,比想源代码实际多了,购买一个注册吗就可以终身使用
/*应该建立有头结点的链表,否则,如果删除的数据刚好是第一个结点时,麻烦就大了。代码改动处较多,已经过不完全测试,可以运行。*/#include#includestructstu{intnumcharname[20]floatsorcestructstu*next}voidoutput_sc(structstu*head){structstu*pfor(p=head->nextpp=p->next)printf("%d%s%f\n",p->num,p->name,p->sorce)printf("\n")}structstu*creat(){structstu*head,*pinti,n,lenlen=sizeof(structstu)printf("pleaseinputthenumberofstudents:")scanf("%d",&n)printf("pleaseinputstudentsdetials\n")head=p=(structstu*)malloc(len)for(i=0inext=(structstu*)malloc(len)scanf("%d%s%f",&p->next->num,p->next->name,&p->next->sorce)p=p->next}p->next=NULLreturn(head)}intdel(structstu*head){structstu*p,*qintnumprintf("请输入要删除的学号:")scanf("%d",&num)if(head->next==NULL){printf("此链表为空\n")return0}p=headwhile(p->next!=NULL){if(p->next->num==num){q=p->nextp->next=q->nextfree(q)return1}p=p->next}printf("未找到相关信息\n")return0}voidoutput_df(structstu*head){structstu*pFILE*fpif((fp=fopen("D:\\data.txt","at+"))==NULL){printf("该文件不存在\n")exit(0)}for(p=head->nextp!=NULLp=p->next)fprintf(fp,"%d%s%f\n",p->num,p->name,p->sorce)fclose(fp)}voiddf_sc(structstu*head){structstusFILE*fpfp=fopen("D:\\data.txt","r")if(fp==NULL){printf("无法打开文件\n")exit(0)}while(!feof(fp)){fscanf(fp,"%d%s%f",&s.num,s.name,&s.sorce)printf("%d%s%f\n",s.num,s.name,s.sorce)}fclose(fp)}voidmain(){structstu*headwhile(1){intnprintf("\t***********************************************\n")printf("\t\t欢迎使用学生成绩管理系统\n")printf("\t\t1.creat2.del\n")printf("\t\t3.out-screen4.out-datafaile\n")printf("\t\t5.datafaile-screen6.exit\n")printf("\t***********************************************\n")printf("\t\tpleaseinputselct1--6\n")printf("Selectplease:")scanf("%d",&n)switch(n){case1:head=creat()breakcase2:del(head)breakcase3:output_sc(head)breakcase4:output_df(head)breakcase5:df_sc(head)breakcase6:exit(0)break}}}建议你重新装一个pubEP现在的PUBWIN都可以破解了免费上网了
PUBEP稍微稳定点!
如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!
vaela
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)