请大家看一下这个问题,顺便帮我指出一下我这个代码哪错了,感谢大家🤧
1条回答 默认 最新
- 加油吧,小杜 2022-03-18 15:34关注
用c++写的,我估计题目的目的不是让你写入文件。只是单纯的做一个系统
#include <iostream> #include <Windows.h> #include <vector> using namespace std; struct Person { string name; int age; string number; }; int main() { vector<Person> res; int operation=3; SetConsoleOutputCP(CP_UTF8); while (true) { cout<<"--------------------手机通讯录--------------------"<<endl; cout<<"----------------请按下面的键盘进行操作--------------"<<endl; cout<<"1.查询联系人...."<<endl; cout<<"2.添加联系人...."; cin>>operation; if(operation==1) { cout<<"输入要查询联系人的名字"; string strName; cin>>strName; for(int i=0;i<res.size();++i) { Person person=res[i]; if(person.name==strName) { cout<<"名字:"<<person.name<<"年龄:"<<person.age<<"电话号码:"<<person.number<<endl; } } } else if(operation==2) { cout<<"请依次输入 名字,年龄 电话号码"; Person person; cin>>person.name>>person.age>>person.number; if(res.size()<50) { res.push_back(person); cout<<"添加成功"<<endl; } else { cout<<"联系人已满"<<endl; } } else { cout<<"无效操作"<<endl; } } system("pause"); return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
- ¥15 CSAPPattacklab
- ¥15 一直显示正在等待HID—ISP
- ¥15 Python turtle 画图
- ¥15 关于大棚监测的pcb板设计
- ¥15 stm32开发clion时遇到的编译问题
- ¥15 lna设计 源简并电感型共源放大器
- ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
- ¥15 Vue3地图和异步函数使用
- ¥15 C++ yoloV5改写遇到的问题