中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

搜狗推廣管家石家莊seo排名公司

搜狗推廣管家,石家莊seo排名公司,微信營(yíng)銷網(wǎng)絡(luò)營(yíng)銷方式,使用asp.net做購(gòu)物網(wǎng)站C自學(xué)精簡(jiǎn)教程 目錄(必讀) 作業(yè)目標(biāo): 這個(gè)作業(yè)中,你需要綜合運(yùn)用之前文章中的知識(shí),來解決一個(gè)相對(duì)完整的應(yīng)用程序。 作業(yè)描述: 1 在這個(gè)作業(yè)中你需要在文本文件中存儲(chǔ)學(xué)生通訊錄的信息,并在程序啟動(dòng)的時(shí)候加載這些…

C++自學(xué)精簡(jiǎn)教程 目錄(必讀)

作業(yè)目標(biāo):

這個(gè)作業(yè)中,你需要綜合運(yùn)用之前文章中的知識(shí),來解決一個(gè)相對(duì)完整的應(yīng)用程序。

作業(yè)描述:

1 在這個(gè)作業(yè)中你需要在文本文件中存儲(chǔ)學(xué)生通訊錄的信息,并在程序啟動(dòng)的時(shí)候加載這些數(shù)據(jù)到內(nèi)存中。

2 在程序運(yùn)行過程中允許用戶用鍵盤輸入信息來完成對(duì)通訊錄數(shù)的增刪改查。

交互示例:

開始代碼

開始代碼不是完整的代碼,需要你填寫一部分代碼,使之完整。

答案在本文最后

當(dāng)你填寫完整之后,運(yùn)行程序和示例的交互輸出一致,就算完成了這個(gè)作業(yè)

開始代碼:

#include <iostream>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <fstream>
using namespace std;class Person
{
public:friend ostream& operator<<(ostream& os, const Person& _person);friend istream& operator>>(istream& is, Person& _person);public:string m_id;string m_name;string m_tel;
};ostream& operator<<(ostream& os, const Person& person)
{os << left << setw(5) << person.m_id << setw(15) << person.m_name << setw(20) << person.m_tel;return os;
}istream& operator>>(istream& is, Person& person)
{//(1) your code // 使用輸入操作符重載,將流中的數(shù)據(jù),提取賦值給person對(duì)象的成員變量中//see https://zhuanlan.zhihu.com/p/412724745return is;
}class PersonManager
{
public:void InputOnePerson(void);bool LoadAllPersonFromFile(const string& fileName);bool DeletePerson(void);bool QueryPersonByName() const;bool QueryPersonByTel() const;void ShowAllPerson(void) const;bool SaveAllPersonToFile(void) const;private:vector<Person> m_allPerson;
};bool PersonManager::DeletePerson(void)
{cout << "Please input person id for delete:";string id;cin >> id;for (auto itr = m_allPerson.begin(); itr != m_allPerson.cend(); ++itr){if (itr->m_id == id){//(2) your code// 容器的erase方法支持刪除容器的元素時(shí),傳入指向元素的迭代器//see https://zhuanlan.zhihu.com/p/441293600}}return false;
}
bool PersonManager::QueryPersonByName() const
{//注意該函數(shù)需要返回bool值cout << "Please input name for query:";string name;cin >> name;for (auto itr = m_allPerson.cbegin(); itr != m_allPerson.cend(); ++itr){if (itr->m_name == name){cout << "Find:" << endl;//(3) your code//see https://zhuanlan.zhihu.com/p/376440190//see https://zhuanlan.zhihu.com/p/376446724}}cout << "not found " << name << endl;return false;
}
bool PersonManager::QueryPersonByTel() const
{cout << "Please input tel for query:";string tel;cin >> tel;for (auto itr = m_allPerson.cbegin(); itr != m_allPerson.cend(); ++itr){if (itr->m_tel == tel){cout << "Find:" << endl;//(4) your code//see https://zhuanlan.zhihu.com/p/376440190//see https://zhuanlan.zhihu.com/p/376446724}}cout << "not found " << tel << endl;return false;
}void PersonManager::ShowAllPerson(void) const
{cout << "All Person:" << endl;cout << left << setw(5) << "id" << setw(15) << "name" << setw(20) << "tel" << endl;for (auto& item : m_allPerson){cout << item << endl;}
}
bool PersonManager::SaveAllPersonToFile(void) const
{ofstream fout("data_saved.txt");//下面的常量迭代器 cbegin cend 中的 c 指的是 const的意思,表示不可以修改容器的元素for (auto itr = m_allPerson.cbegin(); itr != m_allPerson.cend(); ++itr){//(5) your code //see https://zhuanlan.zhihu.com/p/262508774}return true;
}bool PersonManager::LoadAllPersonFromFile(const string& fileName)
{ifstream fin(fileName);if (!fin){cout << "load data failed . file " << fileName << " not exits." << endl;return false;}Person person;while (fin >> person){m_allPerson.push_back(person);}cout << "load data from file success." << endl;return true;
}void PersonManager::InputOnePerson(void)
{cout << "Please input one person:" << endl;cout << "Please input id:";string id;cin >> id;Person person;person.m_id = id;for (auto itr = m_allPerson.cbegin(); itr != m_allPerson.cend(); ++itr){if (itr->m_id == id){cout << id << " already existed! Save failed." << endl;return;}}cout << "Please input name:";string name;cin >> name;person.m_name = name;cout << "Please input tel:";string tel;cin >> tel;person.m_tel = tel;cout << "Input finished, save successed." << endl;m_allPerson.push_back(person);
}int main(int argv, char* argc[])
{PersonManager personMgr;personMgr.LoadAllPersonFromFile("input_data.txt");personMgr.ShowAllPerson();while(true){cout<<"input a commond : "<<endl;cout<<"1 [AddPerson]"<<endl;cout<<"2 [ShowAllPerson]"<<endl;cout<<"3 [QueryPerson by name]"<<endl;cout<<"4 [QueryPerson by tel]"<<endl;cout<<"5 [SaveAllPersonToFile]"<<endl;cout<<"6 [DeletePerson]"<<endl;cout<<"0 [ExitAndSaveChange]"<<endl;int commond;cin>>commond;switch(commond){case 1: { personMgr.InputOnePerson(); break;}case 2: { personMgr.ShowAllPerson(); break;}case 3: { personMgr.QueryPersonByName(); break;}case 4: { personMgr.QueryPersonByTel(); break;}case 5: { personMgr.SaveAllPersonToFile(); break;}case 6: { personMgr.DeletePerson(); break;}case 0: { personMgr.SaveAllPersonToFile(); return 0;}default:{ cout<<"System Exit."<<endl; return 0;}}}return 0;
}

輸入文件

input_data.txt

文件內(nèi)容:

2    zhangsan2      13788889992         
3    zhangsan3      13788889993         
4    zhangsan4      13788889994         
5    wanger         13333333333      

運(yùn)行與輸出

load data from file success.
All Person:
id   name           tel
2    zhangsan2      13788889992
3    zhangsan3      13788889993
4    zhangsan4      13788889994
5    wanger         13333333333
input a commond :
1 [AddPerson]
2 [ShowAllPerson]
3 [QueryPerson by name]
4 [QueryPerson by tel]
5 [SaveAllPersonToFile]
6 [DeletePerson]
0 [ExitAndSaveChange]
2
All Person:
id   name           tel
2    zhangsan2      13788889992
3    zhangsan3      13788889993
4    zhangsan4      13788889994
5    wanger         13333333333
input a commond :
1 [AddPerson]
2 [ShowAllPerson]
3 [QueryPerson by name]
4 [QueryPerson by tel]
5 [SaveAllPersonToFile]
6 [DeletePerson]
0 [ExitAndSaveChange]
1
Please input one person:
Please input id:1
Please input name:zhangsan
Please input tel:13344445555
Input finished, save successed.
input a commond :
1 [AddPerson]
2 [ShowAllPerson]
3 [QueryPerson by name]
4 [QueryPerson by tel]
5 [SaveAllPersonToFile]
6 [DeletePerson]
0 [ExitAndSaveChange]
2
All Person:
id   name           tel
2    zhangsan2      13788889992
3    zhangsan3      13788889993
4    zhangsan4      13788889994
5    wanger         13333333333
1    zhangsan       13344445555
input a commond :
1 [AddPerson]
2 [ShowAllPerson]
3 [QueryPerson by name]
4 [QueryPerson by tel]
5 [SaveAllPersonToFile]
6 [DeletePerson]
0 [ExitAndSaveChange]
3
Please input name for query:zhangsan
Find:
1    zhangsan       13344445555
input a commond :
1 [AddPerson]
2 [ShowAllPerson]
3 [QueryPerson by name]
4 [QueryPerson by tel]
5 [SaveAllPersonToFile]
6 [DeletePerson]
0 [ExitAndSaveChange]
3
Please input name for query:zhang
not found zhang
input a commond :
1 [AddPerson]
2 [ShowAllPerson]
3 [QueryPerson by name]
4 [QueryPerson by tel]
5 [SaveAllPersonToFile]
6 [DeletePerson]
0 [ExitAndSaveChange]
4
Please input tel for query:13344445555
Find:
1    zhangsan       13344445555
input a commond :
1 [AddPerson]
2 [ShowAllPerson]
3 [QueryPerson by name]
4 [QueryPerson by tel]
5 [SaveAllPersonToFile]
6 [DeletePerson]
0 [ExitAndSaveChange]
4
Please input tel for query:1334444
not found 1334444
input a commond :
1 [AddPerson]
2 [ShowAllPerson]
3 [QueryPerson by name]
4 [QueryPerson by tel]
5 [SaveAllPersonToFile]
6 [DeletePerson]
0 [ExitAndSaveChange]
6
Please input person id for delete:4
input a commond :
1 [AddPerson]
2 [ShowAllPerson]
3 [QueryPerson by name]
4 [QueryPerson by tel]
5 [SaveAllPersonToFile]
6 [DeletePerson]
0 [ExitAndSaveChange]
2
All Person:
id   name           tel
2    zhangsan2      13788889992
3    zhangsan3      13788889993
5    wanger         13333333333
1    zhangsan       13344445555
input a commond :
1 [AddPerson]
2 [ShowAllPerson]
3 [QueryPerson by name]
4 [QueryPerson by tel]
5 [SaveAllPersonToFile]
6 [DeletePerson]
0 [ExitAndSaveChange]
5
input a commond :
1 [AddPerson]
2 [ShowAllPerson]
3 [QueryPerson by name]
4 [QueryPerson by tel]
5 [SaveAllPersonToFile]
6 [DeletePerson]
0 [ExitAndSaveChange]
0

最終保存數(shù)據(jù)到文件 data_saved.txt

文件 data_saved.txt 的內(nèi)容為:

2    zhangsan2      13788889992         
3    zhangsan3      13788889993         
5    wanger         13333333333         
1    zhangsan       13344445555       

你的結(jié)果也是這樣嗎?

答案在此

C++自學(xué)精簡(jiǎn)教程 全部答案

學(xué)生完成該作業(yè)展示

另一個(gè)學(xué)生實(shí)現(xiàn)的效果

http://www.risenshineclean.com/news/50640.html

相關(guān)文章:

  • 在線做效果圖的網(wǎng)站網(wǎng)頁(yè)設(shè)計(jì)與制作軟件有哪些
  • 印刷 網(wǎng)站源碼營(yíng)銷型網(wǎng)站建設(shè)
  • 長(zhǎng)沙做網(wǎng)站公司 上聯(lián)網(wǎng)絡(luò)引擎網(wǎng)站推廣法
  • wordpress php教程專業(yè)網(wǎng)站優(yōu)化推廣
  • 沈陽有資質(zhì)做網(wǎng)站的公司有哪些百度推廣開戶費(fèi)用多少
  • 網(wǎng)站建設(shè)創(chuàng)客開網(wǎng)站需要什么流程
  • 網(wǎng)站實(shí)現(xiàn)隸書繁體搜外滴滴友鏈
  • app網(wǎng)站開發(fā)湖南武漢大學(xué)人民醫(yī)院光谷院區(qū)
  • 網(wǎng)站的網(wǎng)站地圖怎么做seo推廣外包
  • 企夢(mèng)網(wǎng)站建設(shè)成功的網(wǎng)絡(luò)營(yíng)銷案例及分析
  • 最新章節(jié) 62.一起來做網(wǎng)站吧網(wǎng)絡(luò)營(yíng)銷有哪些
  • 網(wǎng)站建設(shè)及網(wǎng)絡(luò)營(yíng)銷百度推廣關(guān)鍵詞排名在哪看
  • 網(wǎng)站開發(fā)設(shè)計(jì)思想最新疫情最新情況
  • 茂名建站公司模板秦潔婷seo博客
  • 上海浦東建筑建設(shè)網(wǎng)站推廣方案怎么做
  • 阿里云免費(fèi)網(wǎng)站建設(shè)模板廣告聯(lián)盟大全
  • ??涤蛎W(wǎng)站百度一下首頁(yè)百度一下知道
  • 網(wǎng)站廣告聯(lián)盟怎么做的域名注冊(cè)需要什么條件
  • 做一個(gè)醫(yī)院網(wǎng)站多少錢鏈接檢測(cè)工具
  • wordpress調(diào)用tag鞏義關(guān)鍵詞優(yōu)化推廣
  • 網(wǎng)站建設(shè)公司上海做網(wǎng)站公司哪家好國(guó)內(nèi)永久免費(fèi)的云服務(wù)器
  • 北京 工業(yè)網(wǎng)站建設(shè)公司價(jià)格引流推廣
  • 做網(wǎng)站的人能看到瀏覽的人的信息嗎網(wǎng)址如何被快速收錄
  • 個(gè)人網(wǎng)站 阿里云seowhy論壇
  • 建設(shè)網(wǎng)站深圳全媒體運(yùn)營(yíng)師報(bào)名入口
  • 提供網(wǎng)站建設(shè)備案公司微信上怎么做廣告推廣
  • 吳江和城鄉(xiāng)建設(shè)局網(wǎng)站關(guān)鍵信息基礎(chǔ)設(shè)施安全保護(hù)條例
  • 企業(yè)網(wǎng)站 流程推廣產(chǎn)品怎么發(fā)朋友圈
  • 做網(wǎng)站要看什么書百度搜索廣告收費(fèi)標(biāo)準(zhǔn)
  • 做問卷的幾個(gè)網(wǎng)站如何優(yōu)化關(guān)鍵詞的排名