上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 43 下一页
摘要: 一、插入迭代器 1 /** 2 解释三种插入迭代器的区别。 3 区别在于插入的元素的位置不同: 4 back_inserter,使用push_back实现在容器末端插入。 5 front_inserter, 使用push_front实现在容器前端插入。 6 inserter,使用insert实现插入,它还带有第二个实参:指向插入起始位置的迭代器 7 */ 8 9 #include 10 #include 11 #include 12 #include 13 14 using namespace std;15 16 int main()17 {18 v... 阅读全文
posted @ 2013-09-15 18:13 可笑痴狂 阅读(409) 评论(0) 推荐(0)
摘要: find:#include #include #include using namespace std;int main(){ int a[10]={0,1,2,3,4,5,6,7,8,9}; size_t a_size = sizeof(a)/sizeof(int); list li(a, a+a_size); list::iterator itor1, itor2; for(itor1 = li.begin(); itor1 != li.end(); ++itor1)//打印:0 1 2 3 4 5 6 7 8 9 cout 2 #include 3 #include //cou... 阅读全文
posted @ 2013-09-12 11:59 可笑痴狂 阅读(292) 评论(0) 推荐(0)
摘要: 1 /* 2 编写程序统计并输出所读入的单词出现的次数 3 4 */ 5 /* 6 //代码一:---用map索引实现惊人的简练 7 #include 8 #include 9 10 using namespace std;11 12 int main()13 {14 map word_cnt;15 string word;16 while(cin >> word)17 {18 ++word_cnt[word];//如果查找键值word不存在,那么map中就会插入键值为word的新元素,同时用值初始化或默认构造函数初始化19 ... 阅读全文
posted @ 2013-09-10 10:08 可笑痴狂 阅读(473) 评论(0) 推荐(0)
摘要: 1 #include 2 #include 3 4 using namespace std; 5 6 void ptrswap(int *&v1, int *&v2)//交换指针所指的地址 7 { 8 cout << endl; 9 cout << *v1 << "\t\t" << *v2 << endl;10 int *tmp = v1;11 v1 = v2;12 v2 = tmp;13 cout << *v1 << "\t\t" << *v 阅读全文
posted @ 2013-09-10 10:04 可笑痴狂 阅读(279) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 4 int main() 5 { 6 int ival; 7 while(cin >> ival, !cin.eof()) 8 { 9 if(cin.bad())10 throw runtime_error("IO stream corrupted");11 if(cin.fail())12 {13 cerr 2 3 using namespace std; 4 5 istream & fun... 阅读全文
posted @ 2013-09-10 10:03 可笑痴狂 阅读(400) 评论(0) 推荐(0)
摘要: #include #include #include using namespace std;int main(){ set setInt; vector ivec; for(vector::size_type i = 0; i != 11; ++i) ivec.push_back(i); setInt.insert(ivec.begin(), ivec.end()); setInt.insert(11); set::iterator itor1 = setInt.find(9);// 这个也对,为什么const类型的键值可以用非const的... 阅读全文
posted @ 2013-09-10 10:01 可笑痴狂 阅读(294) 评论(0) 推荐(0)
摘要: 1 /* 2 编写程序读入一些列string和int型数据,将每一组存储在一个pair对象中, 3 然后将这些pair对象存储在vector容器里。 4 */ 5 6 #include 7 #include 8 #include //pair在里边定义 9 10 using namespace std;11 12 int main()13 {14 vector > vp;15 string key;16 int val;17 while(cin >> key >> val)18 {19 //vp.push_b... 阅读全文
posted @ 2013-09-10 10:00 可笑痴狂 阅读(413) 评论(0) 推荐(0)
摘要: 1 /* 2 multimap中的三种遍历方法 3 multimap中如果没有查找到相应元素,则返回的迭代器是依据该元素的排列顺序该键应该插入的位置 4 如果找不到,则方法一和方法二返回的两个迭代器应该相等 5 */ 6 #include 7 #include 8 #include 9 #include 10 11 using namespace std;12 13 int main()14 {15 multimap mulMap;16 mulMap.insert(make_pair("鲁迅", "朝花夕拾"));17 mulMap.in... 阅读全文
posted @ 2013-09-10 09:57 可笑痴狂 阅读(19142) 评论(1) 推荐(3)
摘要: 1.把C++当成一门新的语言学习(和C没啥关系!真的。);2.看《Thinking In C++》,不要看《C++变成死相》;3.看《The C++ Programming Language》和《Inside The C++ Object Model》,不要因为他们很难而我们自己是初学者所以就不看;4.不要被VC、BCB、BC、MC、TC等词汇所迷惑——他们都是集成开发环境,而我们要学的是一门语言;5.不要放过任何一个看上去很简单的小编程问题——他们往往并不那么简单,或者可以引伸出很多知识点;6.会用Visual C++,并不说明你会C++;7.学class并不难,template、STL、g 阅读全文
posted @ 2013-07-27 16:17 可笑痴狂 阅读(611) 评论(2) 推荐(1)
摘要: Max SequenceTime Limit: 3000MSMemory Limit: 65536KTotal Submissions: 14335Accepted: 6012DescriptionGive you N integers a1, a2 ... aN (|ai| 3 #include 4 #include 5 6 using namespace std; 7 8 int num[100001], dp[2][100001]; 9 //dp[i][j] 表示 前 j 项中选择 i 个连续子段所得的最大和,且第 i 个连续子段是以 num[j]结尾的 10 int main... 阅读全文
posted @ 2013-07-05 20:51 可笑痴狂 阅读(984) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 43 下一页