STL-map()数据模版

来源:互联网 发布:照片打印日期软件 编辑:程序博客网 时间:2024/06/13 09:31

map()函数真心是不错,,很久很久我就想学习了,,,只是没有学习成功,今天总算能够简单的运用出来了,,,

而且我觉得,人是要勇于,并且敢于改变的,,,有些东西,,你认为很适合你,可是你换过别的么? 你知道这个才是最适合你的么?

所以我决定了,,,试试DEVC这个编译器,,,别人都用,,,我也用用呗,,,都用了这么长时间的VC6.0了,,缓缓手感,缓缓心情...

而且,自己也要学着把不好的习惯改掉了,,,比如自己不爱打空格,,,以前认为是公认的那是不正确 的,,,现在看了华为的对编程的要求,,

诶,,一点一点慢慢改变吧


#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <iostream>#include <algorithm>#include <map>using namespace std;int main(){map<int , string > m;int a;string str;for(int i=1;i<=5;i++){cin >> a >> str ;m.insert(make_pair(a,str));}int key;while(cin >> key){map<int , string > ::iterator it=m.find(key);if(it == m.end())cout << "no such string!" << endl;elsecout << it->second << endl;}return 0;}


原创粉丝点击