论坛: 编程破解 标题: 通讯录的原程序 复制本贴地址    
作者: morrel [morrel]    论坛用户   登录
#include<conio.h>
#include<stdio.h>
#include<string.h>

#define NULL 0
typedef struct node
{char name[20];
long data;
char address[50];
struct node *next;
}node,*linklist;
linklist l;


save()
{linklist p=l->next;FILE *fp;
if((fp=fopen("TXL.txt","wb"))==NULL)
{printf("cannot open file\n");
return;}
while(p){
if(fwrite(p,sizeof(node),1,fp)!=1)
printf("file write error\n");
p=p->next;}
fclose(fp);
printf("The tongxulu have saved");
}

readin()
{FILE *fp;linklist p=l;
fp=fopen("TXL.txt","rb");
while(p){
fread(p,sizeof(node),1,fp);
p=p->next;
}
fclose(fp);
printf("have read in!");
}

void initiate()
{ int a,i=0;long value;linklist p,r=l;int color;textbackground(1);
cprintf("Please input the length of the linklist:\n");
scanf("%d",&a);
for(i=0;i<a;i++)
{cprintf("Please input the name  , value and  address NO %d:",i);
p=(linklist)malloc(sizeof(node));
scanf("%s%ld%s",p->name,&value,p->address);
p->data=value;
r->next=p;
r=p;
}
p->next=NULL;
}

insert(int i,char name[20],long b,char address[50])
{linklist p=l,s;int j=0;
while(p&&j<i-1){p=p->next;++j;}
if(!p||j>i-1) printf("ERROR!\n");
s=(struct node *)malloc(sizeof(node));
strcpy(s->name,name); s->data=b;
strcpy(s->address,address);
s->next=p->next;
p->next=s;
printf("OK!\n");
}

delete(int i)
{linklist p=l,q;int j=0;
while(p->next&&j<i-1){
p=p->next;++j;
}
if(!(p->next)||j>i-1) printf("ERROR!");
q=p->next;p->next=q->next;
free(q);
printf("OK!\n");
}

search(int j)
{linklist p;int i=1;p=l->next;
while(i<j){p=p->next;i++;}
if(p==NULL)printf("ERROR!");
else{kong(25);
printf("\n                        Personal information");
printf("\n______________________________________________________________");
printf("\nname: %s\ntel: %ld\naddress: %s\n",p->name,p->data,p->address);
printf("______________________________________________________________");
kong(8);
}}

xiugai(int i)
{linklist p;p=l->next;
while(i!=1){p=p->next;i--;}
printf("\nname: %s\ntel: %ld\naddress: %s\n",p->name,p->data,p->address);
printf("You want to change to\n:");
printf("Please input the name  , value and  address NO %d:",i);
scanf("%s%ld%s",p->name,&p->data,p->address);
}

type()
{linklist p=l->next;int color;textbackground(1);
printf("\n<< COMMUNICATION BOOK >>\n");
printf("______________________________________________________________");
while(p!=NULL)
{
printf("\nname: %s\ntel: %ld\naddress: %s\n",p->name,p->data,p->address);
p=p->next;
printf("______________________________________________________________");
}}

kong(int c)
{int j;
for(j=0;j<80*c;j++)printf(" ");}

menu()
{
printf("\nWHAT DO YOU WANT TO DO:\nBuild the communication book-----B\nIncrease a person's information-----I");
printf("\nXIU GAI a person's information-----X\nSave the communication book-----O\nRead in the communication book-----R\n");
printf("\nDelete a person's information-----D\nType all person's information-----T\nSearch a person's information-----S\nEXIT-----E");
}

main()
{int a,i,j,c,e;long value,b; char d,name[20],address[50],your[20],code[20];int color;
textbackground(1);
loopyh: kong(12);
cprintf("\n PLEASE INPUT YOUR REAL NEME TO ACCESS !\n");
cprintf("name:");
scanf("%s",your);
cprintf("\n                                        KEY:");
scanf("%s",code);
if(strcmp(code,"jk021")!=0)
{cprintf("input ERROR!");goto loopyh;}
kong(20);
cprintf("\n    %s, WELLCOME TO USE MY SOFTWARE OF COMMUNICATION BOOK!",your);
printf("\nThe author is Fan Youzhong,you should abide by the law!");
kong(10);
scanf("%c",&d);
scanf("%c",&d);
l=(linklist)malloc(sizeof(linklist));
l->next=NULL;
kong(19);
menu();
kong(8);
loopz:printf("\nYOUR CHOISE:");
scanf("%c",&d);
switch(d)
{case 'I':goto  loopi;
case 'B':goto  loopb;
case 'D':goto  loopd;
case 'T':goto  loopt;
case 'E':goto  loope;
case 'S':goto  loops;
case 'X':goto  loopx;
case 'O':goto  loopo;
case 'R':goto  loopr;
default:goto loopz;
}
loopb: initiate();
goto loopz;
loopi: printf("\nPlease input the insert position:\n");
scanf("%d",&i);
cprintf("\nPlease input the insert the name  , value and  address:\n");
scanf("%s%ld%s",name,&b,address);
insert(i,name,b,address);
goto loopz;
loopd: printf("\nplease input the delete position:\n");
scanf("%d",&i);
delete(i);
goto loopz;
loopx:kong(25);
printf("Input the number of person that you want to change:");
scanf("%d",&e);
xiugai(e);
goto loopz;
loopr:
readin();
goto loopz;
loops:printf("INPUT THE NUMBER PERSON THAT YOU SEARCH:");
scanf("%d",&j);
search(j);
goto loopz;
loopo:save();
goto loopz;
loopt:kong(25);
type();
goto loopz;
loope:kong(25);
cprintf("You are out!\n%s,Thank you for your use!",your);
kong(10);
exit(0);
}


地主 发表时间: 04-03-21 22:34

回复: sniper167 [sniper167]   论坛用户   登录
呵呵
好懂
谢了

B1层 发表时间: 04-03-21 22:44

回复: morrel [morrel]   论坛用户   登录
                              通讯录程序的使用说明
    该程序为范友仲同学所编,此程序为免费共享程序,为了防止他人的破坏,作
者特添加了一个固定的密码,里面一些快捷键需用户注意的是进入的密码为小写字
符,而那些菜单快捷键均为大写字母。以下为使用给程序的用户必读的内容:
    KEY:jk021
    快捷键对应的功能如下:
Build the communication book--------B  初建一个通讯录,即你将几个人的通讯方式输入其中。

Increase a person's information-----I  添加一个人的通讯方式,在此你可以选择添加的位置。

XIU GAI a person's information------X  修改某人的通讯方式,修改前它会显示对应个人原来的信息。

Delete a person's information-------D  删除某人的通讯方式。

Type all person's information-------T  显示该通讯录上所有人的通讯方式,它可以使用户在进行
                                        以上操作后,通讯录的信息一目了蓝。

Search a person's information-------S  查找某人的信息,并将他的信息显示给用户看。

Save the  communication book--------O  保存通讯录信息。
 
Read the  communication book--------R  读入通讯录的信息。
                     
                          EXIT-----E  退出程序使用,它会显示你是否退出,并感谢你的使用。



如果你已经认真读完以上信息,你可以开始使用该程序!
希望你能顺利使用我的程序!
如果在使用过程中遇到什么问题,请与本人联系:youzhongfan@yahoo.com.cn
                                                范友仲
                                                2004年3月14日       
                                               




B2层 发表时间: 04-03-23 13:02

回复: yingzike [yingzike]   论坛用户   登录
用这么多GOTO,有个性呀

B3层 发表时间: 04-03-23 19:21

回复: bailove [bailove]   论坛用户   登录
用这么多GOTO,有个性呀
--------------------
  那叫个性吗? 那叫给自己的程序按不定时炸弹。那一天你想改的时候就有苦头吃了

B4层 发表时间: 04-03-23 19:25

回复: yingzike [yingzike]   论坛用户   登录
唉:-
没人理解/

B5层 发表时间: 04-03-23 19:46

回复: morrel [morrel]   论坛用户   登录
本人初次编这种程序,谢谢你们的指教哦!

B6层 发表时间: 04-03-25 18:24

回复: yuanrulai [yuanrulai]   论坛用户   登录
这位姐姐能不能给点注解呀
这样我好理解一点

B7层 发表时间: 04-03-26 10:58

回复: jianguozhi [jianguozhi]      登录
用VB来编写吗?

B8层 发表时间: 04-03-26 13:30

回复: sniper167 [sniper167]   论坛用户   登录
GOTO多了不太好

B9层 发表时间: 04-03-26 23:27

回复: morrel [morrel]   论坛用户   登录
欢迎大家多提意见哦!!!!

B10层 发表时间: 04-03-30 16:37

回复: morrel [morrel]   论坛用户   登录
如果你们对上面程序有什么不懂的地方或疑问.
请发消息给我或在这留言哦
              我会及时给你答复!!!

B11层 发表时间: 04-04-01 16:31

回复: kailangq [kailangq]   版主   登录


B12层 发表时间: 04-04-02 04:12

回复: andyhuahui [andyhuahui]   论坛用户   登录
loopi: printf("\nPlease input the insert position:\n");
scanf("%d",&i);
cprintf("\nPlease input the insert the name  , value and  address:\n");
scanf("%s%ld%s",name,&b,address);
insert(i,name,b,address);
goto loopz;
loopd: printf("\nplease input the delete position:\n");
scanf("%d",&i);
delete(i);
goto loopz;
loopx:kong(25);
printf("Input the number of person that you want to change:");
scanf("%d",&e);
xiugai(e);
goto loopz;


B13层 发表时间: 04-04-09 09:00

回复: zjs_wy1234 [zjs_wy1234]   论坛用户   登录
GOTO太多了啊 

B14层 发表时间: 04-04-09 20:17

回复: zhoen889 [zhoen889]   论坛用户   登录
fp=fopen("TXL.txt","wb"))==NULL,对于这个文件,可以指明它的路径吗?
如果可以,怎么搞?
多谢!!!

B15层 发表时间: 04-04-10 20:22

回复: morrel [morrel]   论坛用户   登录
它会自动去找的你刚才保存的文件TXL.txt哦!
你没必要去操心.

B16层 发表时间: 04-04-10 23:00

回复: sniper167 [sniper167]   论坛用户   登录
他的意思是想要保存到指定目录

B17层 发表时间: 04-04-10 23:25

回复: morrel [morrel]   论坛用户   登录
对于编程,其实是从小程序的一点一滴的积累中成长的!

B18层 发表时间: 04-05-02 10:44

回复: sniper167 [sniper167]   论坛用户   登录
对头


B19层 发表时间: 04-05-02 13:22

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号