| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1616 人关注过本帖
标题:C语言一大型程序,谁能帮忙改一下(原标题已被更改)
取消只看楼主 加入收藏
ghastman
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2004-6-28
收藏
 问题点数:0 回复次数:2 
C语言一大型程序,谁能帮忙改一下(原标题已被更改)

各位大哥!救命啊!C语言一大型程序,谁能帮忙改一下,明天就要交啦!是个杂志管理软件,要求能够1添加订户信息 2删除订户记录 3统计杂志发行数 4根据姓名和电话查找订户信息 5显示订户清单 6按男女性别排序 7退出,要求能够利用文件进行信息存储,大部分功能已经实现,各位帮帮忙啊。

代码如下:

#include "stdio.h" #include "conio.h" #define NULL 0 #define LEN sizeof(struct list)

typedef struct list { char name[10]; char sex; char add[20]; int ph_num; int price; int year; int month; struct list *next; }List, *linklist; int num; view(linklist HL) { linklist p; p=HL; p=p->next; while(p!=NULL) { printf("Name:%s Sex:%c Add:%s Phone:%d Price:%d Time limit:%d.%d\n",p->name,p->sex,p->add,p->ph_num,p->price,p->year,p->month); p=p->next; } } /*--------------end of view--------------*/

linklist sort_sex(linklist HL) { linklist p,q,s; s=HL; q=HL; p=q->next; if(s->next->sex=='f') { p=p->next; q=q->next; } while(p!=NULL) { if(p->sex=='f') { q->next=p->next; p->next=s->next; s->next=p;; p=q->next; } else { p=p->next; q=q->next; } } view(HL); return (HL); } /*----------------end of sort_sex---------------*/

linklist create() { linklist HL,p,q; int num1; clrscr(); printf("How many subscribers do you want to create?\n"); scanf("%d",&num); num1=num; printf("\nNow,please input the information of the subscriber:\n\n"); HL=(linklist)malloc(sizeof(List)); p=HL; while(num1>0) { p->next=(linklist)malloc(sizeof(List)); p=p->next; printf("name:");scanf(" %s/n",p->name); printf("sex:");scanf(" %c",&p->sex); printf("address:");scanf("%s",p->add); printf("phonenum:");scanf("%d",&p->ph_num);printf("price:");scanf("%d",&p->price);printf("year:");scanf("%d",&p->year);printf("month:");scanf(" %d",&p->month); num1--; } p->next=NULL; HL=sort_sex(HL); return HL; } /*----------------end of create-----------*/

rewrite(struct list *p3) { struct list *p; FILE *fp; fp=fopen("b_data.acc","wb"); p=p3; do { fwrite(p,LEN,1,fp); p=p->next; }while(p!=NULL); fclose(fp); }

add() { int i; int m; char c; struct list *p1; FILE *fp; p1=NULL; fp=fopen("b_data.acc","ab+"); printf("Input imformation\n"); printf("name:");scanf("%s",p1->name); printf("sex:");scanf(" %c",&p1->sex); printf("address:");scanf(" %s",p1->add); printf("phonenum:");scanf("%ld",&p1->ph_num); printf("price:");scanf("%d",&p1->price); printf("year:");scanf("%d",&p1->year); printf("month:");scanf("%d",&p1->month);

p1->next=NULL; fwrite(p1,LEN,1,fp); fclose(fp); printf("\t\t\tcontinne to book ? [y][n]\n\t\t\t"); lea: c=getchar(); switch(c) { case 'y':add();break; case 'n':return; default: goto lea; } clrscr(); }

/*--------------end of add------------*/

linklist delete(linklist HL) { linklist p,q; int Year,Month; clrscr(); p=HL; q=p; p=q->next; printf("Please input the limit time:"); scanf("%d%d",&Year,&Month); while(p!=NULL) { if(p->year<Year) { q->next=p->next; p=q->next; num--; } else { p=p->next; q=q->next; } } p=HL->next; q=HL; while(p!=NULL) { if(p->year==Year && p->month<Month) { q->next=p->next; p=q->next; num--; } else { p=p->next; q=q->next; } } view(HL); return HL; } /*-------------end of delete-----------*/

linklist count(linklist HL) { linklist p; int number; number=0; p=HL; p=p->next; while(p!=NULL) { number++; p=p->next; } num=number; printf("We have %d subscribers in limit time.",number); return HL; } /*-------------end of count------------*/

linklist search(linklist HL) { linklist p; int p_num; int cmp,flag,find; char nm[10]; flag=0; find=0; p=HL; p=p->next; clrscr(); printf("Please in put the subscriber's name and phone number:"); scanf(" %s",nm); scanf("%d",&p_num); while(p!=NULL && flag!=1) { cmp=strcmp(nm,p->name); if(cmp==0 && p->ph_num==p_num) { printf("\n\nName:%s Sex:%c Add:%s Phone:%d Price:%d Limit time:%d.%d\n",p->name,p->sex,p->add,p->ph_num,p->price,p->year,p->month); flag=1; } else { find++; p=p->next; } } if(find==num) { printf("Sorry, we can not find it"); } return HL; } /*-------------end of search--------*/

linklist sort(linklist head,linklist hl) { linklist HL,p,q; p=head; q=p; p=q->next; while(p!=NULL) { p=p->next; q=q->next; } q->next=hl->next; HL=head; view(HL); return HL; } /*-------------end of sort------------*/

linklist sort_1(linklist Hl,int nn) { int n,flag,num1,num2,cpa; linklist p,q,s,l,ll; p=Hl; s=p; p=p->next; q=p; p=q->next; flag=0; num1=nn-1; for(n=0;n<num1;n++) { cpa=q->ph_num; num2=nn-n-1; while(p!=NULL) { if(cpa>p->ph_num) { ll=q; l=p; cpa=p->ph_num; p=p->next; q=q->next; flag=0; } else { p=p->next; q=q->next; flag++; } } if(flag!=num2) { ll->next=l->next; l->next=s->next; s->next=l; q=l->next; s=l; p=q->next; flag=0; } else { s=s->next; q=s->next; p=q->next; flag=0; } } /* view(HL); */

return Hl; } /*--------------end of sort--------------*/

main() { linklist HL,head,p,q,hl; int num_fe,num_ma; int cho,flag; flag=0; while(flag==0) { clrscr(); printf("============================================\n\n"); printf(" 1. Create 2. Add \n\n"); printf(" 3. Delete 4. Count \n\n"); printf(" 5. Search 6. Display \n\n"); printf(" 7. Sort 8. Exit \n\n"); printf("============================================\n\n"); scanf("%d",&cho); switch(cho) { case 1: HL=create(); getch(); break; case 2: HL=add(HL); getch(); break; case 3: HL=delete(HL); getch(); break; case 4: HL=count(HL); getch(); break; case 5: HL=search(HL); getch(); break; case 6: view(HL); getch(); break; case 7: num_fe=0;num_ma=0; p=HL; head=HL; q=p; p=q->next; hl=(linklist)malloc(sizeof(List)); while(p->sex!='m') { num_fe++; p=p->next; q=q->next; } q->next=NULL; hl->next=p; num_ma=num-num_fe; head=sort_1(head,num_fe); hl=sort_1(hl,num_ma); HL=sort(head,hl); getch(); break; case 8: exit(); default: printf("ERROR,choose again!"); getch(); } } } /*--------------------end of main------------------*/

[此贴子已经被ChenMo于2004-06-29 13:34:09编辑过]

搜索更多相关主题的帖子: C语言 订户 int char 
2004-06-28 19:30
ghastman
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2004-6-28
收藏
得分:0 

各位大虾帮帮忙吧,明早就要交了

2004-06-28 20:23
ghastman
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2004-6-28
收藏
得分:0 
pp
2004-06-28 21:47
快速回复:C语言一大型程序,谁能帮忙改一下(原标题已被更改)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.054890 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved