用链表实现的通讯录的功能

要求:制作一个电子通讯录,通过该通讯录能存入好友 ID 号、 姓名) (英文)、 手机号码、家庭住址、公司电话


模块

主界面:主要显示软件功能。
1. 添加好友信息。
2. 列表好友信息。(包含排序功能)
3. 搜索好友
4. 删除好友


  添加好友:
用户输入 1后,让用户输入好友信息。添加成功或失败都需要提示用户
  列表好友:
用户输入 2后,好友信息升序排列。
  搜索好友:
用户输入 3后,让用户输入将要搜索好友姓名查询。如果未搜索到请友好提示。如果搜索到,显示出该好友信息。
  删除好友:
用户输入 4后,让用输入将要删除好友姓名删除,如果存在同名的多个好友,则列表出,所有同名的好友信息,让用户通过输入 ID 号删除。提示用户删除成功。



#ifndef __LINKLIST_H__
#define __LINKLIST_H__


#define TRUE   1
#define FALSE -1
#define SIZE  50
typedef struct _people
{
int id;
char name[SIZE];
char tel[SIZE];
char address[SIZE];
char ctel[SIZE];
}LinkData;


typedef struct _node
{
LinkData data;
struct _node *next;
}Node;
int Quit();


int Sort_List(Node *h);


void Choice(Node *h);


void Search(Node *h);


void Add(Node *h);


void Delete(Node *h);


Node *Find_Element2(Node *h, LinkData d, int *x);


int Delete_Id(Node *h, int d);


int Find_nElement(Node *h, LinkData d);


void Display_Pos(Node *h, int x);


int Fun(int x, Node *h);


void MainInterface();


int Init(Node *h);


Node *Create_List();


void Display_List(Node *h);


int Insert_Last(Node *h, LinkData data);


int Insert_Head(Node *h,LinkData data);


int Insert_Pos(Node *h, int pos, LinkData data);


int Delete_Pos(Node *h, int pos);


int Delete_Data(Node *h, LinkData data);


int Find_Element(Node *h, LinkData d, int *x);


int Get_Element(Node *h, int pos, LinkData *x);


int Reverse_List(Node *h);


int Get_Len(Node *h);


int Clean_List(Node *h);


int Destroy(Node *h);


#endif





#include "LinkList.h"
#include <stdlib.h>
#include <stdio.h>


Node *Create_List()
{
Node *node = (Node *)malloc(sizeof(Node)/sizeof(char));
if(node == NULL)
return NULL;
node->next = NULL;
return node;
}


int Fun(int x,Node *h)
{
    MainInterface();
switch(x)
{
case 1:
//MainInterface();
Add(h);
break;
case 2:
//MainInterface();
Sort_List(h);
       Display_List(h);
break;
case 3:
//MainInterface();
Search(h);
break;
case 4:
//MainInterface();
Delete(h);
break;
case 5:
system("clear");
return FALSE;
//Quit();
default:
printf("输入错误,请重新输入\n");
break;

}
return TRUE;
}




int Sort_List(Node *h)
{
if(h == NULL || h->next == NULL || h->next->next == NULL)
return FALSE;
int n = Get_Len(h);
int i,j;
for(i=0; i<n-1; i++)
{
Node *pre = h->next;
Node *cur = h->next->next;
Node *tmp = h;
for(j=0; j<n-1-i; j++)
{
i

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值