-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail_book.c
89 lines (76 loc) · 1.31 KB
/
mail_book.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <stdio.h>
#include <string.h>
#include "mail_book.h"
#include "tools.h"
static int count = 0; // 有效联系人
static char name[50][20] = {};
static char tel[50][12] = {};
static char sex[50] = {};
void add(void)
{
if(50 <= count)
{
printf("系统正在升级,请稍候!\n");
return;
}
int i = 0;
while(sex[i]) i++;
printf("请输入姓名、性别、电话:");
scanf("%s %c %s",name[i],&sex[i],tel[i]);
count++;
msg_show("联系人添加成功!",1.5);
}
void del(void)
{
char key[20] = {};
printf("请输入要删除的联系人姓名:");
scanf("%s",key);
for(int i=0; i<50; i++)
{
if(sex[i])
{
if(0 == strcmp(key,name[i]))
{
sex[i] = 0;
count--;
msg_show("联系人删除成功!\n",1.5);
return;
}
}
}
msg_show("查无此人,请检查!\n",1.5);
}
void mod(void)
{
printf("%s\n",__func__);
}
void find(void)
{
char key[20] = {};
printf("请输入要查找的关键字:");
scanf("%s",key);
for(int i=0; i<50; i++)
{
if(sex[i])
{
if(strstr(name[i],key) || strstr(tel[i],key))
{
printf("%s %s %s\n",
name[i],'w' == sex[i]?"女":"男",tel[i]);
}
}
}
anykey_continue();
}
void show(void)
{
for(int i=0; i<50; i++)
{
if(sex[i])
{
printf("%s %s %s\n",
name[i],'w' == sex[i]?"女":"男",tel[i]);
}
}
anykey_continue();
}