九度1069
来源:互联网 发布:大数据客户流失预警 编辑:程序博客网 时间:2024/06/03 23:05
涉及string的substr、find函数,以及map及其iterator使用方式。
#include <iostream>#include <algorithm>#include <cstdlib>#include <string.h>#include <string>#include <map>using namespace std;int main(){ int n,m; int i; int index; string str,id,info; map<string,string> amap; map<string,string>::iterator it; while(cin>>n) { cin.ignore(); amap.clear(); for(i=0;i<n;i++) { getline(cin,str); index=str.find(" "); id=str.substr(0,index); info=str.substr(index+1); amap.insert(pair<string,string>(id,info)); } cin>>m; for(i=0;i<m;i++) { cin>>id; it=amap.find(id); if(it!=amap.end()) cout<<it->first<<" "<<it->second<<endl; else cout<<"No Answer!"<<endl; } } return 0;}
0 0
- 九度oj 1069
- 九度题目1069
- 九度1069
- 九度OJ 1069: 查找学生信息
- 九度OJ 1069 二分查找问题
- 九度题目1069:查找学生信息
- 九度OJ 1069 查找学生信息
- 【九度】题目1069:查找学生信息
- 九度 oj 1069题解题思路
- 【九度OJ】:九度OJ 1050
- 【九度OJ】:九度OJ 1053
- 【九度OJ】:九度OJ 1056
- 【九度OJ】:九度OJ 1059
- 【九度OJ】:九度OJ 1206
- 人生九度
- 九度oj1181
- 九度oj1207
- 九度oj1182
- Android学习笔记之ListView
- pring bean生命周期详解
- 美团O2O排序解决方案——线下篇
- 151. Reverse Words in a String
- .NET 类库和工具
- 九度1069
- 根据inode编号来删除文件或目录
- Ruby的require工作
- Spring Bean 生命周期
- 并发容器
- HappyNumber解题报告
- Swift闭包详解
- 林锐高质量c编程阅读心得
- 状态压缩(2)+模拟枚举(2)--poj3279(能力题)