<span style="font-size:18px;">#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<malloc.h>
#include<conio.h>
#define LEN sizeof(struct ab)
#define ZIP 7
#define PHONE 7
#define MAX 100
struct ab
{
char name[10];
char addr[10];
char zip[ZIP];
char phone[PHONE];
struct ab *next;
};
struct ab *head;
void search(struct ab *head);
struct ab *add(struct ab *head);
struct ab *del(struct ab *head);
void alter(struct ab *head);
void print(struct ab *head);
void thefirst();
int n;</span>
<span style="font-size:18px;">#include"head.h"
void main()
{
n=0;
head=(struct ab *)malloc(LEN);
thefirst();
}
void thefirst()
{
char c;
system("CLS");
puts("**************************************");
puts(" 通讯录 ");
puts(" 1、查询 ");
puts(" 2、加入 ");
puts(" 3、删除 ");
puts(" 4、改动 ");
puts(" 5、显示 ");
puts(" 6、返回 ");
puts("**************************************");
c=getch();
system("CLS");
switch(c)
{
case '1':search(head);break;
case '2':head=add(head);thefirst();break;
case '3':head=del(head);thefirst();break;
case '4':alter(head);break;
case '5':print(head);break;
case '6':printf("BYE BYE!\n");
}
}</span>
<span style="font-size:18px;">#include"head.h"
void search(struct ab *head)
{
char str[10];
struct ab *p;
p=head;
printf("please input the name you want to search!\n");
scanf("%s",str);
if(p==NULL)
{
printf("please input the information first!press any key to thefirst \n");
getch();
thefirst();
}
system("CLS");
for(;p&&strcmp(str,p->name);p=p->next);
if(p)
printf("%10s\n%10s\n%10s\n%10s\n",p->name,p->addr,p->zip,p->phone);
else
printf("there is no information about the people you want!\n");
getch();
thefirst();
}</span>
<span style="font-size:18px;">#include"head.h"
struct ab *add(struct ab *head)
{
struct ab *p1,*p2,*p3;
char c[10];
printf("please input the name!\n");
scanf("%s",c);
p1=head;
if(n==0)
{
strcpy(p1->name,c);
printf("please input the address!\n");
scanf("%s",p1->addr);
printf("please input the zip!\n");
scanf("%s",p1->zip);
printf("please input the phone!\n");
scanf("%s",p1->phone);
printf("%s\n",p1->phone);
p1->next=NULL;
n++;
}
else
{
p3=(struct ab *)malloc(LEN);
strcpy(p3->name,c);
printf("please input the address!\n");
scanf("%s",p3->addr);
printf("please input the zip!\n");
scanf("%s",p3->zip);
printf("please input the phone!\n");
scanf("%s",p3->phone);
if(strcmp(c,p1->name)<0)
{
head=p3;
p3->next=p1;
}
else
{
for(;p1&&strcmp(c,p1->name)>0;p2=p1,p1=p1->next);
if(p1==NULL)
{
p2->next=p3;
p3->next=NULL;
}
else
{
p2->next=p3;
p3->next=p1;
}
n++;
}
}
return head;
}</span>
<span style="font-size:18px;">#include"head.h"
struct ab *del(struct ab *head)
{
struct ab *p1,*p2;
char c[10];
p1=head;
printf("please input the name you want to delete\n");
scanf("%s",c);
for(;p1&&strcmp(c,p1->name);p2=p1,p1=p1->next);
if(p1==NULL)
{
printf("not find!press any key to thefirst \n");
getch();
}
else if(p1==head)
head=p1->next;
else
p2->next=p1->next;
return head;
}</span>
<span style="font-size:18px;">#include"head.h"
void alter(struct ab *head)
{
char str[10];
struct ab *p;
p=head;
printf("please input the name you want to search!\n");
scanf("%s",str);
for(;p&&strcmp(str,p->name);p=p->next);
if(p)
{
printf("please input the address!\n");
scanf("%s",p->addr);
printf("please input the zip!\n");
scanf("%s",p->zip);
printf("please input the phone!\n");
scanf("%s",p->phone);
}
else
{
printf("not find!press any key to thefirst \n");
getch();
}
thefirst();
}
</span>
<span style="font-size:18px;">#include"head.h"
void print(struct ab *head)
{
struct ab *p;
for(p=head;p;p=p->next)
{
printf("%10s%10s%10s%10s\n",p->name,p->addr,p->zip,p->phone);
}
getch();
thefirst();
}</span>

C语言实现通讯录的更多相关文章

  1. C语言之通讯录的模拟实现

    C语言之通讯录的模拟实现 在C语言学习结束之际,谨以此篇文章来对C语言的学习告一段落. 纲要: 通讯录的静态版本 通讯录的动态版本 通讯录的带文件版本 因为三种实现方法除了储存形式不同,其他都基本相同 ...

  2. c语言实现通讯录管理系统(c课程设计)

    工具:Visual C++6.0 说明: 本系统基于C语言实现班级通讯录管理系统,为大一时学习C语言刚入门所做的课程设计.功能包括增.删.查.改等,非常适合初学者练手.通讯录包括的个人信息有姓名.学号 ...

  3. C语言-《通讯录》

    黑白的通讯录 --1-- 需求分析 1.1 需求 1.2 原型展示 1.3 功能分析 --2-- 代码实现 2.1 外部声明.变量.宏 2.2 模块实现 ----------------------- ...

  4. Iphone 英语语言下通讯录排序问题

    Iphone 如果把界面语言设置成English,那么通讯录默认排序是通过拼音来排的,如果联系人信息中没有设置名字的拼音,那么这些联系人都会被放到#中. 批量添加拼音的解决方案: https://gi ...

  5. 2、C语言实现通讯录

    main函数入口: //test.c #include<stdio.h> #include<stdlib.h> #include<string.h> #includ ...

  6. C语言可以开发哪些项目?

    C语言是我们大多数人的编程入门语言,对其也再熟悉不过了,不过很多初学者在学习的过程中难免会出现迷茫,比如:不知道C语言可以开发哪些项目,可以应用在哪些实际的开发中--,这些迷茫也导致了我们在学习的过程 ...

  7. (一〇一)集成静态库RHAddressBook实现OC访问通讯录

    使用官方的AddressBook框架仅能使用C语言访问通讯录,十分不便,这里介绍集成第三方框架RHAddressBook的方法,该框架可以通过OC访问和操作通讯录. 该框架是一个静态库,集成比较复杂. ...

  8. C语言可以开发哪些项目?(转)

    原文地址:https://www.cnblogs.com/shiyanlou/p/6098661.html 知乎:https://www.zhihu.com/question/20564904 C语言 ...

  9. 17个C语言可以做的小案例项目

    C语言是我们大多数人的编程入门语言,对其也再熟悉不过了,不过很多初学者在学习的过程中难免会出现迷茫,比如:不知道C语言可以开发哪些项目,可以应用在哪些实际的开发中……,这些迷茫也导致了我们在学习的过程 ...

随机推荐

  1. hdu2489 Minimal Ratio Tree

    hdu2489 Minimal Ratio Tree 题意:一个 至多  n=15 的 完全图 ,求 含有 m 个节点的树 使 边权和 除 点权和 最小 题解:枚举 m 个 点 ,然后 求 最小生成树 ...

  2. java与C#的简单比较

    刚刚看完java视频,做了个简单图: 新知识不多,大多是与以往知识的相互碰撞,一下做了java与C#的简单比较:                         Java C# 主类名与文件名 必须一 ...

  3. POJ 1258-Agri-Net (Kruskal)

    题目链接:Agri-Net 最小生成树水题,数组开的和题目描写叙述一样,可是就是RE,有填了个0,还好这个题用 库鲁斯卡尔 敲了一遍,发现了点问题,曾经写的库鲁卡尔模板有点问题,多写了步没用的操作,已 ...

  4. SVN 1.8.x 服务器安装(转)

    目录[-] 一. SVN 服务器下载.安装 1. 关于 Subversion 1.8.11 2. 兼容性问题 3. 安装包下载 3.1 VisualSVN 3.2 Win32Svn 3.3 SlikS ...

  5. Swift - 跳跃吃苹果游戏开发(SpriteKit游戏开发)

    下面通过一个样例演示如何实现飞行道具的生成,以及道具碰撞拾取. 样例说明: 1,屏幕从右到左不断地生成苹果飞过来(苹果高度随机) 2,点击屏幕可以让熊猫跳跃 3,熊猫碰到苹果,苹果消失 运行效果: 样 ...

  6. 关于storyboard的一点学习记录

    1.storyboard中“Main storyboard file base name”这个用来注册启动是所需要的storyboard 文件名称.当我们程序启动的时候,我们的工程就会根据这一项来自动 ...

  7. Python 自动化测试报告HTMLTestRunner

    HTMLTestRunner 是Python的一个测试报告 参考网址: http://tungwaiyip.info/software/HTMLTestRunner.html https://pypi ...

  8. Documentation | AnsibleWorks

    Documentation | AnsibleWorks   Welcome to the Ansible documentation! Ansible is an IT automation too ...

  9. Oracle Tablespace Transportation

    前提:进行表空间传输需要用户有SYSDBA的系统权限,被移动的表空间是自包含的表空间,不应有依赖于表空间外部对象的对象存在.确定是否自包含可使用系统包DBMS_TTS中的TRANSPORT_SET_C ...

  10. 5款帮助简化的HTML5 Audio开发的Javascript类库

    HTML5的audio标签提供了我们方便控制声音的功能,可是使用原生的HTML5来开发声音或者音乐相关的项目仍旧很的麻烦.在今天这篇文章中,我们将介绍5款帮助你简化开发的javascript audi ...