免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

C++學習日記通訊錄管理-創新互聯

通訊錄管理

創新互聯公司-專業網站定制、快速模板網站建設、高性價比陳巴爾虎網站開發、企業建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式陳巴爾虎網站制作公司更省心,省錢,快速模板網站建設找我們,業務覆蓋陳巴爾虎地區。費用合理售后完善,十載實體公司更值得信賴。

#include
using namespace std;
#include
constexpr auto MAX = 1000;

struct person
{
?string name;//名字
?int age{};//年齡
?int sex{};//性別 1男 2女
?string phone;//電話號
?string addr;//地址
};

struct adderessbooks
{
?struct person person_array[MAX];
?int m_size{};
};

void add_person(adderessbooks* abs)
{
?if (abs->m_size == MAX)
?{
??? ?cout<< "通訊錄已滿"<< endl;
??? ?return;
?}
?else
?{
??? ?//姓名
??? ?string name;
??? ?cout<< "請輸入姓名"<< endl;
??? ?cin >>name;
??? ?abs->person_array[abs->m_size].name = name;
??? ?//性別
??? ?int sex=0;
??? ?cout<< "請輸入性別,1為男,2為女"<< endl;
??? ?while (true)
??? ?{
??? ??? ?cin >>sex;
??? ??? ?if (sex == 1 || sex == 2)
??? ??? ?{
??? ??? ??? ?abs->person_array[abs->m_size].sex = sex;
??? ??? ??? ?break;
??? ??? ?}
??? ??? ?else
??? ??? ?{
??? ??? ??? ?cout<< "輸入格式錯誤,請重新輸入"<< endl;
??? ??? ?}
??? ?}
??? ?//年齡
??? ?int age=0;
??? ?cout<< "請輸入年齡"<< endl;
??? ?cin >>age;
??? ?abs->person_array[abs->m_size].age = age;
??? ?//電話
??? ?string phone;
??? ?cout<< "請輸入電話號"<< endl;
??? ?cin >>phone;
??? ?abs->person_array[abs->m_size].phone = phone;
??? ?//地址
??? ?string addr;
??? ?cout<< "請輸入地址"<< endl;
??? ?cin >>addr;
??? ?abs->person_array[abs->m_size].addr = addr;
??? ?//更新通訊錄人數
??? ?abs->m_size++;

??? ?cout<< "成功添加"<< endl;
??? ?system("pause");
??? ?system("cls");
?}
}

void show_person(adderessbooks* abs)
{
?if (abs->m_size == 0)
?{
??? ?cout<< "無聯系人"<< endl;
??? ?system("pause");
??? ?system("cls");
?}
?else
?{
??? ?for (int i = 0; i< abs->m_size; i++)
??? ?{
??? ??? ?cout<< "姓名 ?"<< abs->person_array[i].name<< "\t";
??? ??? ?cout<< "性別 "<< (abs->person_array[i].sex == 1 ? "男":"女" )<< "\t";
??? ??? ?cout<< "年齡 ?"<< abs->person_array[i].age<< "\t";
??? ??? ?cout<< "電話號 ?"<< abs->person_array[i].phone<< "\t";
??? ??? ?cout<< "住址 ?"<< abs->person_array[i].addr<< endl;
??? ?}
??? ?system("pause");
??? ?system("cls");
?}
}

int is_exist(adderessbooks* abs, string name)
{
?for (int i = 0; i< abs->m_size; i++)
?{
??? ?if (abs->person_array[i].name == name)
??? ?{
??? ??? ?return i;
??? ?}
?}
?return -1;
}

void delete_person(adderessbooks* abs)
{
?cout<< "請輸入要刪除人姓名"<< endl;
?string name;
?cin >>name;
?int num=is_exist(abs, name);
?if (num == -1)
?{
??? ?cout<< "查無此人"<< endl;
??? ?system("pause");
??? ?system("cls");
?}
?else
?{
??? ?for (int i = num; i< abs->m_size; i++)
??? ?{
??? ??? ?abs->person_array[i] = abs->person_array[i + 1];
??? ?}
??? ?abs->m_size--;
??? ?cout<< "刪除成功"<< endl;
??? ?system("pause");
??? ?system("cls");
?}
}

void find_person(adderessbooks* abs)
{
?cout<< "請輸入要查找人姓名"<< endl;
?string name;
?cin >>name;
?int num = is_exist(abs, name);
?if (num == -1)
?{
??? ?cout<< "查無此人"<< endl;
??? ?system("pause");
??? ?system("cls");
?}
?else
?{
??? ?cout<< "姓名 ?"<< abs->person_array[num].name<< "\t";
??? ?cout<< " 性別 "<< (abs->person_array[num].sex == 1 ? "男" : "女")<< "\t";
??? ?cout<< " 年齡 "<< abs->person_array[num].age<< "\t";
??? ?cout<< "電話號 ?"<< abs->person_array[num].phone<< "\t";
??? ?cout<< "住址 ?"<< abs->person_array[num].addr<< endl;
??? ?system("pause");
??? ?system("cls");
?}
}

void change_person(adderessbooks* abs)
{
?cout<< "請輸入要修改人姓名"<< endl;
?string name;
?cin >>name;
?int num = is_exist(abs, name);
?if (num == -1)
?{
??? ?cout<< "查無此人"<< endl;
??? ?system("pause");
??? ?system("cls");
?}
?else
?{
??? ?//姓名
??? ?string name;
??? ?cout<< "請輸入姓名"<< endl;
??? ?cin >>name;
??? ?abs->person_array[num].name = name;
??? ?//性別
??? ?int sex;
??? ?cout<< "請輸入性別,1為男,2為女"<< endl;
??? ?while (true)
??? ?{
??? ??? ?cin >>sex;
??? ??? ?if (sex == 1 || sex == 2)
??? ??? ?{
??? ??? ??? ?abs->person_array[num].sex = sex;
??? ??? ??? ?break;
??? ??? ?}
??? ??? ?else
??? ??? ?{
??? ??? ??? ?cout<< "輸入格式錯誤,請重新輸入"<< endl;
??? ??? ?}
??? ?}
??? ?//年齡
??? ?int age;
??? ?cout<< "請輸入年齡"<< endl;
??? ?cin >>age;
??? ?abs->person_array[num].age = age;
??? ?//電話
??? ?string phone;
??? ?cout<< "請輸入電話號"<< endl;
??? ?cin >>phone;
??? ?abs->person_array[num].phone = phone;
??? ?//地址
??? ?string addr;
??? ?cout<< "請輸入地址"<< endl;
??? ?cin >>addr;
??? ?abs->person_array[num].addr = addr;
??? ?cout<< "成功修改"<< endl;
??? ?system("pause");
??? ?system("cls");
?}
}

void empty_person(adderessbooks* abs)
{
?abs->m_size = 0;
?cout<< "已清空"<< endl;
?system("pause");
?system("cls");
}

void show_menu() //菜單
{
?cout<< "************************"<< endl;
?cout<< "***** 1.添加聯系人 *****"<< endl;
?cout<< "***** 2.顯示聯系人 *****"<< endl;
?cout<< "***** 3.刪除聯系人 *****"<< endl;
?cout<< "***** 4.查找聯系人 *****"<< endl;
?cout<< "***** 5.修改聯系人 *****"<< endl;
?cout<< "***** 6.清空聯系人 *****"<< endl;
?cout<< "***** 0.退出通訊錄 *****"<< endl;
?cout<< "************************"<< endl;
}

int main()
{
?adderessbooks abs;
?abs.m_size = 0;
?int select_num = 0;
?while (true)
?{
??? ?show_menu();
??? ?cin >>select_num;
??? ?switch (select_num)
??? ?{
??? ?case 1:
??? ??? ?add_person(&abs);
??? ??? ?break;
??? ?case 2:
??? ??? ?show_person(&abs);
??? ??? ?break;
??? ?case 3:
??? ??? ?delete_person(&abs);
??? ??? ?break;
??? ?case 4:
??? ??? ?find_person(&abs);
??? ??? ?break;
??? ?case 5:
??? ??? ?change_person(&abs);
??? ??? ?break;
??? ?case 6:
??? ??? ?empty_person(&abs);
??? ??? ?break;
??? ?case 0:?
??? ??? ?cout<< "歡迎下次使用"<< endl;
??? ??? ?system("pause");
??? ??? ?return 0;
??? ??? ?break;
??? ?default:
??? ??? ?break;
??? ?}
?}
?system("pause");
?return 0;
}

你是否還在尋找穩定的海外服務器提供商?創新互聯www.cdcxhl.cn海外機房具備T級流量清洗系統配攻擊溯源,準確流量調度確保服務器高可用性,企業級服務器適合批量采購,新人活動首月15元起,快前往官網查看詳情吧

分享名稱:C++學習日記通訊錄管理-創新互聯
新聞來源:http://newbst.com/article0/coegoo.html

成都網站建設公司_創新互聯,為您提供用戶體驗品牌網站制作外貿網站建設網站維護網站收錄App開發

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都網站建設公司