满意答案

这个是我编的,用数组和链表两种功能实现的通讯录

基本能满足你的要求!!

代码如下:

#include "stdlib.h"

#define NEW (struct node *)malloc(sizeof(struct node))

struct student

{ char name[10],tel[11];

}a[20];

struct node

{ char name[20],tel[11];

struct node *next;

};

main()

{ struct student *jianli(),*delete(struct student *);

struct student *charu(struct student *);

void xianshi(struct student *);

struct node *create(),*delnode(struct node*,char *);

struct node *insert(struct node *,struct node *,char *);

void prlist(struct node *);

struct student *p;

struct node *head=NULL,*stu;

char s[80],name[20],q[80];

int c,w;

a:;

system("cls");

printf("\nEnter your choice\n");

printf("1.SHUZU\n2.LIANBIAO\n0.Quit\n");

gets(q);

w=atoi(q);

switch(w)

{ case 1:

do

{ do

{ printf("----------------------------------------------\n");

printf("******************Phone book******************\n");

printf("----------------------------------------------\n");

printf(" | | <1> Add a note | |\n");

printf(" | | <2> Show the list | |\n");

printf(" | | <3> Delete a note | |\n");

printf(" | | <4> Insert a note | |\n");

printf(" | | <0> Quit | |\n");

printf("----------------------------------------------\n");

printf(" Enter your choice(0-4):");

gets(s);

c=atoi(s);

}while(c<0||c>4);

system("cls");

switch(c)

{ case 1: p=jianli();break;

case 2: xianshi(p);break;

case 3: printf("\nPlease input the name to deleted\n");

p=delete(p);break;

case 4: printf("\nPlease input the new name\n");

p=charu(p);break;

}

}while(c);goto a;

case 2:

do

{ do

{printf("----------------------------------------------\n"); printf("******************Phone book******************\n"); printf("----------------------------------------------\n"); printf(" | | <1> Add a note | |\n"); printf(" | | <2> Show the list | |\n"); printf(" | | <3> Delete a note | |\n"); printf(" | | <4> Insert a note | |\n"); printf(" | | <0> Quit | |\n"); printf("----------------------------------------------\n"); printf(" Enter your choice(0-4):"); gets(s); c=atoi(s); }while(c<0||c>4);

system("cls");

switch(c)

{ case 1: head=create();break;

case 2: prlist(head);break;

case 3: printf("\nInput the name to deleted\n");

gets(name);

head=delnode(head,name);break;

case 4: stu=NEW;

printf("\nInput the new node\n");

printf("name:");

gets(stu->name);

printf("tel:");

gets(stu->tel);

stu->next=NULL;

printf("\nInsert position\n");

printf("name:");

gets(name);

head=insert(head,stu,name);

}

}while(c);goto a;

}

}

#include "string.h"

struct student *jianli()

{ char c1[10],c2[11];

int i=0;

printf("name:");

gets(c1);

while(strlen(c1)!=0)

{ strcpy(a[i].name,c1);

printf("tel:");

gets(c2);

strcpy(a[i].tel,c2);

i++;

printf("name:");

gets(c1);

}

return a;

}

#include "string.h"

struct student *delete(struct student *p)

{ char c1[10];

int i=0,j,l=0;

while(strlen(p[i].name)!=0)

i++;

printf("name:");

gets(c1);

for(j=0;j<=i+1;j++)

if(strcmp(c1,p[j].name)==0)

{p[j]=p[j+1]; l=j;}

while(l

{p[l]=p[l+1]; l++;}

return p;

}

#include "string.h"

struct student *charu(struct student *p)

{ char c1[10],c2[11];

int i=0;

while(strlen(p[i].name)!=0)

i++;

printf("name:");

gets(c1);

strcpy(p[i].name,c1);

printf("tel:");

gets(c2);

strcpy(p[i].tel,c2);

return p;

}

#include "string.h"

void xianshi(struct student *p)

{ int i=0;

printf("name\ttel\n\n");

while(strlen(p[i].name)!=0)

{ printf("%s\t%s\n",p[i].name,p[i].tel);

i++;}

}

#include "stdlib.h"

#include "string.h"

#define NEW (struct node *)malloc(sizeof(struct node))

struct node *create()

{ struct node *h;

struct node *p,*q;

char name[20];

h=q=NULL;

printf("name:");

gets(name);

while(strlen(name)!=0)

{ p=NEW;

if(p==NULL)

{ printf("Allocation failure\n");

exit(0);

}

strcpy(p->name,name);

printf("tel:");

gets(p->tel);

p->next=NULL;

if(h==NULL)

h=p;

else

q->next=p;

q=p;

printf("name:");

gets(name);

}

return h;

}

struct node *insert(struct node *head,struct node *p0,char *x)

{ struct node *p,*q;

if(head==NULL)

{ head=p0;

p0->next=NULL;

}

else

{ p=head;

while(strcmp(x,p->name)!=0&&p->next!=NULL)

{ q=p;p=q->next;}

if(strcmp(x,p->name)==0)

{ if(p==head)

head=p0;

else

q->next=p0;

p0->next=p;

}

else

{ p->next=p0;

p0->next=NULL;

}

}

return head;

}

void prlist(struct node *head)

{ struct node *p;

p=head;

printf("name\ttel\n\n");

while(p!=NULL)

{ printf("%s\t%s\n",p->name,p->tel);

p=p->next;

}

}

struct node *delnode(struct node *head,char *x)

{ struct node *p,*q;

if(head==NULL)

{ printf("this is a empty list.");

return head;

}

p=head;

while(strcmp(x,p->name)!=0&&p->next!=NULL)

{ q=p;p=p->next;}

if(strcmp(x,p->name)==0)

{ if(p==head)

head=p->next;

else

q->next=p->next;

free(p);

}

else

printf("Not found.");

return head;

}

01分享举报

通讯录c语言总体程序框图,用c语言编写一个通讯录,并对他进行增加,查询,删除,修改,显示记录等操作,要写出源代码并画出流程图...相关推荐

  1. C语言编程>第六周 ① 编写一个录入函数:用来从键盘接收n个整型数并存放在一个整型数组中。 在主函数中调用该函数计算出这n个整数之和。

    例题:编写一个录入函数:用来从键盘接收n个整型数并存放在一个整型数组中. 在主函数中调用该函数计算出这n个整数之和. 代码如下: /*代码分析:录入函数需要两个参数:一个参数是需要用来存储数字的数组, ...

  2. C语言编程>第五周 ⑤ 编写一个程序,从键盘输入X,Y,Z 3个数, 编写函数计算3个数的立方和并返回计算结果。

    例题:编写一个程序,从键盘输入X,Y,Z 3个数, 编写函数计算3个数的立方和并返回计算结果. 第一种方法: 代码如下: #include <stdio.h> int abc(int,in ...

  3. C语言试题四十一之请编写一个函数,用来删除字符串中的所有空格。

    1. 题目 请编写一个函数function,它的功能是:用来删除字符串中的所有空格. 2 .温馨提示 C语言试题汇总里可用于计算机二级C语言笔试.机试.研究生复试中C程序设计科目.帮助C语言学者打好程 ...

  4. C语言试题二十五之编写一个函数float function(double h),函数的功能使对变量h中的值保留2位小数,并对第三位进行四舍五入(规定h中的值位正数)。

    1. 题目 编写一个函数float function(double h),函数的功能使对变量h中的值保留2位小数,并对第三位进行四舍五入(规定h中的值位正数). 2 .温馨提示 C语言试题汇总里可用于 ...

  5. C语言试题二十四之编写一个函数unsigned function(unsigned w),w使一个大于10的无符号整数,若w是n(n≥2)位的整数,则函数求出w后n-1位的数作为函数值返回。

    1. 题目 请编写一个函数unsigned function(unsigned w),w使一个大于10的无符号整数,若w是n(n≥2)位的整数,则函数求出w后n-1位的数作为函数值返回. 比如:w是1 ...

  6. 编写一个c语言程序 求e的值,编写一个程序求e的值_相关文章专题_写写帮文库

    时间:2019-05-15 01:58:18 作者:admin 3.2 代数式的值 做课人 尹圣军 [教学目标] 知识与技能 能解释代数式值的实际意义,了解代数式值的概念. 过程与方法 经历观察.实验 ...

  7. Go语言环境安装,验证go语言环境、使用文本编辑器编写一个go hello world,Go lang IDE安装,在golang中新建一个go程序

    1 Golang语言环境安装包下载 https://www.golangtc.com/ 下载: go1.9.2.windows-amd64.msi 和 go1.9.2.windows-amd64.zi ...

  8. C语言试题二十八之编写函数function功能是:从字符中删除指定的字符,同一字母的大、小写按不同字符处理。

    1. 题目 编写函数function,该函数的功能是:从字符中删除指定的字符,同一字母的大.小写按不同字符处理. 2 .温馨提示 C试题汇总里可用于计算机二级C语言笔试.机试.研究生复试中C程序设计科 ...

  9. 猜价格游戏c语言课程设计,肿么用C#编写一个猜价格的小程序?

    c语言制作UI界面需要相关的UI库 如windows操作系统本身就提供了UI的接口 一个简单的示例代码如下 #include LRESULT CALLBACK WndProc(HWND,UINT,WP ...

最新文章

  1. 1.5K star量,上古老番变4K,B站开源超分辨率算法
  2. linux之awk命令解读
  3. 数据库出现的bug原因以及解决方法
  4. 鸿蒙系统用没有安卓的代码,套壳?不存在!纯鸿蒙系统不含任何安卓代码,其他手机厂商可使用...
  5. mysql赋予权限的时候报错_想要远程连接MySQL,赋予root权限没用啊?一直报语法错误...
  6. C#中using关键字的作用及其用法(转)
  7. ASP.NET2.0中的App_Data文件的作用
  8. vscode调试Flutter
  9. 解决在IE浏览器中JQuery.resize()执行多次的方法(转)
  10. 在java中class是什么意思_java 中Class? 中的?代表什么意思?
  11. maven的全局setting及用户setting
  12. freemarker英文日期显示成中文问题
  13. 豆瓣电影Top250数据分析
  14. 计算机图形学——MFC绘图基础
  15. 通过Python爬取QQ空间说说并通过Pyechart进行可视化分析
  16. Android 安卓动画 属性动画 - 移动动画
  17. Lab1过程及心得体会
  18. 上传图片到php服务器
  19. 一个单身程序员的新年寄语
  20. 关于2022考研报名,这些你需要知道

热门文章

  1. 又一款度盘不限速下载神器,无需登录,10M/s!
  2. Android阿里、京东、美团等大厂面试Android篇
  3. HTTP协议工作原理、工作过程
  4. Matplotlib中的colorbar调整:等值线、分色个数(附完整画图代码)
  5. 手机语音服务器在哪里设置,腾讯地图联合王者荣耀推出妲己语音导航服务(安装设置方法)...
  6. 数据与广告系列二十六:知识迁移的Embedding应用,智能化定向的解药
  7. 基于ssm奖励制度查询系统mysql
  8. js输出类面试题(四)
  9. EM算法学习笔记与三硬币模型推导
  10. 2022-2028全球及中国先进核磁共振成像可视化系统行业研究及十四五规划分析报告