当前位置:网站首页>[untitled] 8 simplified address book
[untitled] 8 simplified address book
2022-07-03 06:23:00 【Little black's tail】
1)
220529
#include<iostream>
using namespace std;
#include<string>
#define MAX 100
void showmeau() {// Display directory function
cout << "\t Welcome to contacts " << endl;
cout << "\t\t Please select 0-4" << endl;
cout << "\t1. Add personnel " << endl;
cout << "\t2. Show people " << endl;
cout << "\t3. Find people " << endl;
cout << "\t4. Remove personnel " << endl;
cout << "\t0. sign out " << endl;
}
void exitTuichu() {// Exit the address book function
cout << " Thank you for using , Quit successfully " << endl;
return;
}
// Define human structure
struct Person {
string name;
string eleDianhua;
};
struct Person personarr[MAX];// Define the address book structure
int sizerenshu = 0;// Record the number of people deposited
void tianJiarenyuan() {// Add personnel function
if (sizerenshu <= MAX) {
string name1;
string eleDIanhua1;
Person per1;
cout << " Please enter the name of the person " << endl;
cin >> name1;
cout << " Please enter the phone number of the person " << endl;
cin >> eleDIanhua1;
per1.name = name1;
per1.eleDianhua = eleDIanhua1;
//int sizerenshu = sizeof(personarr) / sizeof(personarr[0]);
personarr[sizerenshu] = per1;
sizerenshu++;
cout << " Add success " << endl;
}
else
{
cout << " The number is full , Please delete and add " << endl;
return;
}
cout << endl;
}
void showPer() {// Show address book owner function
if (sizerenshu>0)
{
for (int i = 0;i < sizerenshu;i++) {
cout << " full name \t" << personarr[i].name << "\t Telephone \t" << personarr[i].eleDianhua << endl;
}
}
else {
cout << " The current address book is empty " << endl;
}
}
void Cazaoren() {// Find human function , Find by name
if (sizerenshu > 0) {
string name2;
cout << " Please enter the name of the person you are looking for " << endl;
cin >> name2;
for (int i = 0;i < sizerenshu;i++) {
if (personarr[i].name == name2) {
cout << " Find success " << endl;
cout << " full name \t" << personarr[i].name << "\t Telephone \t" << personarr[i].eleDianhua << endl;
}
else {
cout << " To find the failure " << endl;
}
}
}
else {
cout << " The current address book is empty " << endl;
}
}
void Sancu() {// Personnel delete function
if (sizerenshu > 0) {
for (int i = 0;i < sizerenshu;i++) {
personarr[i] = {};
cout << " Delete successful " << endl;
sizerenshu--;
}
}
else {
cout << " The current address book is empty " << endl;
}
}
// Test functions
void text() {
while (true) {
showmeau();
int xuanZhe = 0;
int xuanze = 0;
cin >> xuanze;
xuanZhe = (int)xuanze;
cout << xuanze << endl;
cout << xuanZhe << endl;
switch (xuanZhe) {
case 1://1. Add personnel
tianJiarenyuan();
system("pause");
system("cls");
break;
case 2://2. Show people
showPer();
system("pause");
system("cls");
break;
case 3://3. Find people
Cazaoren();
system("pause");
system("cls");
break;
case 4://4. Remove personnel
Sancu();
system("pause");
system("cls");
break;
case 0://0. sign out
exitTuichu();
system("pause");
system("cls");
return;
}
}
}
// The main function
int main() {
text();
//int sizerenshu = sizeof(personarr) / sizeof(personarr[0]);
//cout << sizerenshu << endl;
system("pause");
}
//. Mail list
//1. Add personnel
//2. Show people
//3. Find people
//4. Remove personnel
//0. sign out
Purpose :
- Summarize and apply ,
- The implementation of address book is relatively simple
- switch Statement choice of function selection ,
- while Statement to repeat the function ,
- for Statement to traverse the address book array members 、 add to 、 Display and other functions of the cycle
- Functions are written separately
- if Statement to judge whether the address book is empty
The process :
- Function options display functions --- Implement exit function --- Define personnel structure 、 Structure array --- Define global variables sizerenshu--- Other functions
analysis
- ① With add , Show , lookup , Delete and other functions . Unmodified functions . Write functions separately in different functions , It can realize the concretization of functions , It should be process oriented .
- ② Using the operation of cycling and screen clearing can make the interface more concise ,
- ③ Application return Exit function directly , You can exit the loop and keep the result true
- ④ Application sizerenshu The global variable of the array makes reasonable statistics on the members stored in the array , It is convenient and enriches other functions
There are known problems :
- ① The name entered is not , Judge whether the phone is legal
- ② Dialing is not implemented , Check functions such as dialing
边栏推荐
- Kubesphere - build Nacos cluster
- Cannot get value with @value, null
- Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
- PMP笔记记录
- How to scan when Canon c3120l is a network shared printer
- ssh链接远程服务器 及 远程图形化界面的本地显示
- 论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》
- Selenium ide installation recording and local project maintenance
- Leetcode solution - 01 Two Sum
- Characteristics and isolation level of database
猜你喜欢

Kubernetes notes (VIII) kubernetes security

SSH link remote server and local display of remote graphical interface

使用 Abp.Zero 搭建第三方登录模块(一):原理篇

Cesium 点击获取模型表面经纬度高程坐标(三维坐标)

【5G NR】UE注册流程

表达式的动态解析和计算,Flee用起来真香

Kubesphere - build Nacos cluster

Oauth2.0 - use database to store client information and authorization code

23 design models

After the Chrome browser is updated, lodop printing cannot be called
随机推荐
JMeter performance automation test
Shell conditional statement
Kubernetes notes (II) pod usage notes
Printer related problem record
Learning notes -- principles and comparison of k-d tree and IKD tree
【无标题】8 简易版通讯录
Decision tree of machine learning
认识弹性盒子flex
从小数据量分库分表 MySQL 合并迁移数据到 TiDB
Merge and migrate data from small data volume, sub database and sub table Mysql to tidb
[set theory] equivalence relation (concept of equivalence relation | examples of equivalence relation | equivalence relation and closure)
Use selenium to climb the annual box office of Yien
Zhiniu stock -- 03
GPS坐标转百度地图坐标的方法
JMeter linked database
Use @data in Lombok to simplify entity class code
Docker advanced learning (container data volume, MySQL installation, dockerfile)
Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
Mysql database binlog log enable record
Characteristics and isolation level of database