<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. 云计算被视为继大型计算机、个人计算机、互联网之后的第4次IT产业革命,顺应了当前各行业整合计算资源和服务能力的要求(转)

    云计算被视为继大型计算机.个人计算机.互联网之后的第4次IT产业革命,顺应了当前各行业整合计算资源和服务能力的要求,成为引领当今世界信息技术变革的主力军.越来越多的金融企业认识到只有与云计算结合,才能 ...

  2. [置顶] Java 8全面解析!不知道的来看看那!

    java8的面世惊动了不少业界人员,让我们一起来看看吧! 函数式接口 函数式接口是只定义了一个抽象方法的接口.Java 8引入了FunctionalInterface注解来表明一个接口打算成为一个函数 ...

  3. [Unity3D]Unity3D游戏开发之《愤慨的小鸟》弹弓实现

    各位朋友,大家晚上好, 我是秦元培.欢迎大家关注我的博客,我的博客地址是blog.csdn.net/qinyuanpei.今天我们来做一个高端大气上档次的东西. 我相信大家都玩过一款叫做<愤慨的 ...

  4. Vertica数据库操作

    删除主键(Vertica数据库的主键值并非唯一的): SELECT ANALYZE_CONSTRAINTS('fb_s.c_log'); 找到key名,再: ALTER TABLE fb_s.c_lo ...

  5. 如何将自定义标签封装成一个Jar包

    当我们在一个web应用中开发好一些自定义标签的时候,这些自定义标签通常有标签处理器Java类,和一个描述这些标签tld文件,如果我们想在以后别的web工程中还能用上这些标签,可以将这些自定义标签封装在 ...

  6. Linux IP代理筛选系统(shell+proxy)

    代理的用途 其实,除了抓取国外网页需要用到IP代理外,还有很多场景会用到代理: 通过代理访问一些国外网站,绕过被某国防火墙过滤掉的网站 使用教育网的代理服务器,可以访问到大学或科研院所的内部网站资源 ...

  7. java 中通过label跳出双重for 循环

    java 中如何跳出双重for 循环 java跳出循环是使用break语句的,break默认跳出当前循环(包括for循环.while循环),当使用双层循环时,可通过label从内层循环跳出.有关对比的 ...

  8. poj 3082多边形相交 'Roid Rage

    题意是判断多边形是否相交 主要的思路就是判断每一个点是否在另外的多变形内 判断一个点是否在另一个多边形内主要思路是: 判断的那个点向左边做射线,如果射线与多边形的交点为奇数个则在多边形内,偶数个则不在 ...

  9. 第十六周oj刷题——Problem J: 填空题:静态成员---计算学生个数

    Description 学生类声明已经给出.在主程序中依据输入信息输出实际建立的学生对象个数,以及全部学生对象的成绩总和. Input 学生个数 相应学生个数的学生信息(姓名    年龄    成绩) ...

  10. 链栈之C++实现

    链栈是借用单链表实现的栈.其不同于顺序栈之处在于: 1.链栈的空间是程序运行期间根据需要动态分配的,机器内存是它的上限.而顺序栈则是 静态分配内存的. 2.链栈动态分配内存的特性使得它一般无需考虑栈溢 ...