map的三种插入操作
Xredman
posted @ Jun 13, 2009 05:46:00 AM
in 以前博文
, 1197 阅读
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
int main()
{
map<string, int> M;
M.clear();
/*用下标初始化*/
M[string("i1")] = 1;
/*用pair初始化*/
M.insert(pair<string, int>(string("i2"), 2));
/*直接用内置的value_type初始化*/
M.insert(map<string, int>::value_type ("i3", 3));
map<string, int>::iterator p = M.begin();
while(p != M.end())
{
cout<<"first: "<<p->first<<" secnd: "<<p->second<<endl;
p++;
}
return 0;
}
#include <algorithm>
#include <string>
#include <map>
using namespace std;
int main()
{
map<string, int> M;
M.clear();
/*用下标初始化*/
M[string("i1")] = 1;
/*用pair初始化*/
M.insert(pair<string, int>(string("i2"), 2));
/*直接用内置的value_type初始化*/
M.insert(map<string, int>::value_type ("i3", 3));
map<string, int>::iterator p = M.begin();
while(p != M.end())
{
cout<<"first: "<<p->first<<" secnd: "<<p->second<<endl;
p++;
}
return 0;
}
Sep 07, 2023 05:17:35 PM
The PSEB 9th Important Question Paper 2024 are Designed in Accordance with the Latest Blueprint for PSEB Exam, It is quite necessary that Students Start Practicing with These Punjab Board Model Test Paper 2024, Last Year Exam Paper will give Students an Exact idea of what final Exam, Students can Download Study Materiel Subject Wise Pdf Format Available Our Website.Students who are Appearing for PSEB 9th Model Paper 2024 the PSEB Exam can Prepare ahead and aim to Pass marks in the Punjab Board Exam, help of Punjab Board Previous Question Paper 2024 of English, Hindi, Mathematics, Music, Punjabi, Science, Home Science, Social Science,They can Download These Punjab Board Solved Question Paper 2024.
Jan 19, 2024 03:58:49 AM
Board Model Papers 2024 Download with Suggestions for 10th Class Textbooks 2024 Pdf Download and SSLC New Syllabus Sample Question Paper 2024 and different types of model papers boardmodelpaper.com and question papers for following the website and Arts, Science, Commerce Stream Subject Wise Solved Question Bank for Hindi & English Medium Students with Exam Pattern & Blueprint and subject Wise with 11th & 12th Question Bank 2024 for General & Vocational Course Languages & Subjects Important Question for the above link.