请大家看一下这个问题,顺便帮我指出一下我这个代码哪错了,感谢大家🤧
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 求指导ADS低噪放设计
- ¥15 CARSIM前车变道设置
- ¥50 三种调度算法报错 有实例
- ¥15 关于#python#的问题,请各位专家解答!
- ¥200 询问:python实现大地主题正反算的程序设计,有偿
- ¥15 smptlib使用465端口发送邮件失败
- ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
- ¥15 对于squad数据集的基于bert模型的微调
- ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
- ¥20 steam下载游戏占用内存