当前位置:网站首页>C程序实例1--个人通讯录管理系统
C程序实例1--个人通讯录管理系统
2022-06-10 20:50:00 【sinat_41752325】
个人通讯录管理系统
已实现的功能:
1. 界面选择是否进入通讯录;
2. 一次添加多条联系人;
3. 显示全部联系人;
未实现的功能:
1. 退出程序后通讯录不会保存;
2. 退出系统后需要重新打开程序才可进入系统;
通讯录信息包括:姓名、工作单位、固定电话、手机号、关系、EMAIL、QQ。
| 数据变量 | 类型 | 说明 |
| name | char [30] | 姓名 |
| telephone | char [30] | 固定电话 |
| mobilephone | char [30] | 手机号 |
| type | char [30] | 关系 |
| char [30] | qq号 | |
| char [64] | ||
| department | char [512] | 工作单位 |
包含的功能:添加联系人、显示全部联系人。
添加联系人:首先需要输入添加几个联系人,然后分别添加每个联系人的信息,输入信息时需要与添加的信息内容保持一致;
代码:
#include <stdio.h>
#include <stdlib.h>
#define MAX_CHARS 512
#define MAX_CONTACTS_COUNT 256
enum {
SYS_CONTACTS_INPUT=1,
SYS_CONTACTS_OUTPUT=2,
SYS_CONTACTS_EXIT = 3,
};
// 结构体 记录要输入或显示的信息,包括 姓名、单位、固定电话、手持电话、关系、email、qq
typedef struct T_SYS_CONTACTS{
char name[30]; // 姓名
char telephone[30]; // 固定电话
char mobilphone[30]; // 手持电话
char type[30]; // 关系
char qq[30]; // qq
char email[64]; // email
char department[MAX_CHARS]; // 单位
}ContactSys;
void InputContacts(); // 添加联系人
void OutputContacts(); // 显示联系人
ContactSys g_contacts[MAX_CONTACTS_COUNT]; // 通讯录里的联系人信息
int nContacts; // 联系人个数
int main()
{
int isAccess = -1; // 是否进入通讯录管理系统
printf("【0】 进入个人通讯录管理系统\n");
printf("【非0】 退出程序\n");
printf("请输入你需要完成的操作:");
scanf("%d",&isAccess);
if(0 != isAccess)
return 0;
printf("*******************欢迎访问个人通讯录系统^_^****************************\r\n\n");
do
{
printf("\t序号【1】:添加联系人.\r\n");
printf("\t序号【2】:显示联系人.\r\n");
printf("\t序号【3】:退出系统\r\n\n");
printf("请输入你需要完成的操作序号:");
int nCommand;
scanf("%d",&nCommand);
switch(nCommand)
{
case SYS_CONTACTS_INPUT:
InputContacts();
break;
case SYS_CONTACTS_OUTPUT:
OutputContacts();
break;
case SYS_CONTACTS_EXIT:
{
printf("退出个人通讯录管理系统\r\n");
}
break;
}
if(SYS_CONTACTS_EXIT == nCommand)
break;
} while (1);
printf("\r\n*******************退出个人通讯录系统^_^****************************\r\n\n");
system("pause");
return 0;
}
void InputContacts()
{
printf("\n##开始添加联系人\r\n请输入添加的联系人的个数(<256):");
scanf("%d",&nContacts);
printf("\t请输入联系人的信息,输入时使用Tab键对齐要输入的信息\r\n\t\t姓名\t单位\t固定电话\t移动手机\t分类\tEMAIL\t\tQQ\t\r\n");
for(int i=0;i<nContacts;i++)
{
printf("\t\t");
scanf("%s\t%s\t%s\t\t%s\t\t%s\t%s\t%s",&g_contacts[i].name,
&g_contacts[i].department,
&g_contacts[i].telephone,
&g_contacts[i].mobilphone,
&g_contacts[i].type,
&g_contacts[i].email,
&g_contacts[i].qq);
}
printf("\n添加联系人结束\r\n\n");
}
void OutputContacts()
{
printf("\n##显示联系人\r\n");
printf("姓名\t单位\t固定电话\t移动手机\t分类\tEMAIL\t\tQQ\t\r\n");
for(int i=0;i<nContacts;i++)
{
printf("%s\t%s\t%s\t\t%s\t\t%s\t%s\t%s\r\n",g_contacts[i].name,
g_contacts[i].department,
g_contacts[i].telephone,
g_contacts[i].mobilphone,
g_contacts[i].type,
g_contacts[i].email,
g_contacts[i].qq);
if((i+1) %10 ==0)
printf("-------------------------------------------------------------\r\n");
}
printf("\n显示联系人结束\r\n\n");
}
运行结果:

边栏推荐
- [nk] Niuke monthly competition 51 f-average question
- 旋转菜单3.0
- How to realize the marketing purpose of small program integral mall
- Are you still writing the TS type code
- 【北大青鸟昌平校区】职教与普教协调发展,今年的中考会容易吗?
- Constructing the implementation strategy of steam education for children
- Abbexa AML1 DNA binding ELISA Kit instructions
- 2021年平均工资出炉,IT行业不出所料
- C language learning review -- 1 basic knowledge review
- 在模仿学习中进步的智能机器人
猜你喜欢

ThinkPHP v6.0.x反序列化漏洞复现

Abbkine column exkine Pro animal cell / tissue Total Protein Extraction Kit

Standard dual airbags, starting from 48900 for butcher Chang'an Lumin

What should be paid attention to when designing Multilayer PCB?

解读创客空间下的教育新生态

SoC development environment and hardware development preparation
CentOS7安装MySQL8的超级详细教程(无坑!)

Redis cache penetration

登堂入室之soc开发环境及硬件开发准备

C language -- 11 branch statement if else
随机推荐
[qingniaochangping campus of Peking University] the coordinated development of vocational education and general education, will this year's high school entrance examination be easy?
Which city should I go to after I graduate from it? Which position has a high salary? Which companies have good treatment?
【phpstorm】 No data sources are configured to run this SQL and provide advanced c
Will your company choose to develop data center?
In 2021, the average salary will be released, and the IT industry will not be surprised
Detailed steps and actual records of SQL server2019 installation (available for hands-on test)
Leetcode advanced path - Search insertion location
Quick start to VISSIM simulation
Understanding of related concepts of target detection
Leetcode advanced path - the first unique character in a string
用少儿编程思维塑造青少年领悟能力
Calculus review 1
Only three steps are needed to learn how to use low code thingjs to connect with Sen data Dix data
Introduction to database system -- Chapter 1 -- Introduction (important knowledge points)
Factory and strategy mode implementation scheme of coupons
MySQL数据库如何查看表占用空间大小
自媒体视频创作如何选择领域?
构建幼儿Steam教育实施策略
C language -- 3 variables for beginners
Abbkine column exkine Pro animal cell / tissue Total Protein Extraction Kit