当前位置:网站首页>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");
}
运行结果:

边栏推荐
- The system needs to scan all the files and try to identify the cover of the video
- SQL第四练:字符串处理函数
- C language ---9 first knowledge of macros and pointers
- Leetcode advanced path - delete duplicates in the sorting array
- [nk] 牛客月賽51 G計算題
- Shell implements SSH login and executes commands
- Rotate navigation bar
- Mysql之将查询结果插入到其它表中
- 用少儿编程思维塑造青少年领悟能力
- 详解MATLAB中与矩阵运算有关的算术运算符(加、减、乘、除、点乘、点除、乘方)
猜你喜欢

Exec function of PHP

Factory and strategy mode implementation scheme of coupons

Which city should I go to after I graduate from it? Which position has a high salary? Which companies have good treatment?

Course design of imitation pottery ticket of wechat applet

C language -- 1 c language cognition

If else is too easy to use? (understanding this article will further improve your logic)

软件测试工程师是做什么的?

C language ---5 initial string, escape character and comment

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

Interview Essentials - basic knowledge of synchronized underlying principles
随机推荐
北大青鸟昌平校区:高中学历可以学UI吗?
Exec function of PHP
在Oracle表中进行关键词搜索的过程
Abbexa 1,3-dipalmitonin CLIA kit solution
C language ---5 initial string, escape character and comment
数据库系统概论 ---- 第一章 -- 绪论(重要知识点)
C language -- 10 first knowledge of structure
Leetcode advanced road - 136 A number that appears only once
[1024 ways to play windows azure] 75 Fast cloud database migration seamlessly migrate alicloud RDS SQL server to azure SQL databas
About type-C
[nk] Niuke monthly competition 51 f-average question
[qingniaochangping campus of Peking University] the coordinated development of vocational education and general education, will this year's high school entrance examination be easy?
Before we learn about high-performance computing, let's take a look at its history
Codeforces Round #798 (Div. 2)
Detailed steps and actual records of SQL server2019 installation (available for hands-on test)
在模仿学习中进步的智能机器人
2022-06-09 RK817 PMU 電池溫度檢測
Leetcode advanced road - 69 Square root of X
Interpreting the new ecology of education in maker space
初中毕业生,选择中职学校也可以升入高等学府