上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 31 下一页

2012年3月4日

C++ Primer 第11章 习题11.15

摘要: //11.15.cpp //使用unique_copy算法 //将一个list对象中不重复的元素复制到一个空是vector对象中 #include<iostream> #include<list> #include<vector> #include<algorithm> #include<iterator> using namespace std; int main() { int ia[]={1,2,3,4,100,5,100}; list<int> ilst(ia,ia+7); vector<int> iv 阅读全文

posted @ 2012-03-04 00:29 1.曲待续 阅读(95) 评论(0) 推荐(0) 编辑

C++ Primer 第11章 习题11.14

摘要: 【解答】假设vector容器中ivec中的序列为1 2 3 4 100 5 100,将ivec复制给list容器ilst,并将ivec中值为100的元素替换为0值使用inserter实现:replace_copy(ivec.begin(),ivec.end(), inserter(ilst,ilst.begin()),100,0);在输出序列中的固定位置实现插入,因此ilst中的序列为:12 3 4 0 5 0使用back_inserter实现:replace_copy(ivec.begin(),ivec.end(), back_inserter(ilst),100,0);总是在输出序列的前端 阅读全文

posted @ 2012-03-04 00:15 1.曲待续 阅读(129) 评论(0) 推荐(0) 编辑

2012年3月3日

C++ Primer 第4章 习题4.35

摘要: //4.35.cpp //读入一组string类型的数据,并将它们存储在vector中 //接着,把vector对象复制给一个字符指针数组 //为vector中的每个元素创建一个新的字符数组, //并把该vector元素的数据复制到相应的字符数组中 //然后把指向该数组的指针插入字符指针数组中 //输出建立vector对象和数组的内容 #include<iostream> #include<vector> #include<string> using namespace std; int main() { vector<string> svec; 阅读全文

posted @ 2012-03-03 23:00 1.曲待续 阅读(129) 评论(0) 推荐(0) 编辑

C++ Primer 第4章 习题4.34

摘要: //4.34.cpp //读入一组string类型的数据,并将它们存储在vector中 //接着,把该vector对象复制给一个字符指针数组。 //为vector中的每个元素创建一个新的字符数组, //并把该vector元素的数据复制到相应的字符数组中 //最后把指向该数组的指针插入字符指针数组 #include<iostream> #include<vector> #include<string> using namespace std; int main() { vector<string> svec; string str; //输入vec 阅读全文

posted @ 2012-03-03 22:36 1.曲待续 阅读(117) 评论(0) 推荐(0) 编辑

2012年3月1日

C++ Primer 第11章 习题11.9

摘要: //泛型算法中对容器元素从新排序的算法 //11.9.cpp //读入文本文件 //统计长度不小于4的单词,并输出输入序列中不重复的单词 #include<iostream> #include<fstream> #include<vector> #include<algorithm> #include<string> using namespace std; //用于将单词按长度排序的比较函数 bool isShorter(const string &s1,const string &s2) { return s1.s 阅读全文

posted @ 2012-03-01 18:33 1.曲待续 阅读(116) 评论(0) 推荐(0) 编辑

C++ Primer 第11章 习题11.6

摘要: //11.6.cpp //使用fill_n编写程序 //将一个int型序列的值设为0 #include<iostream> #include<vector> #include<iterator> using namespace std; int main() { vector<int> ivec; ivec.resize(10); //使该vector容器包含10个元素 fill_n(ivec.begin(),ivec.size(),0); //输出vector对象中的元素 for(vector<int>::iterator iter 阅读全文

posted @ 2012-03-01 17:08 1.曲待续 阅读(92) 评论(0) 推荐(0) 编辑

C++ Primer 第11章 习题11.3

摘要: //11.3.cpp //用accumulate统计vector<int>容器对象中的元素之和 #include<iostream> #include<vector> #include<numeric> using namespace std; int main() { vector<int> ivec; int ival; int sum; //读入int型元素带vector对象中 cout<<"Enter some integers(Ctrl+z to end):"<<endl; whi 阅读全文

posted @ 2012-03-01 17:07 1.曲待续 阅读(104) 评论(0) 推荐(0) 编辑

C++ Primer 第11章 习题11.1

摘要: //11.1.cpp //algorithm头文件定义一个名为count的函数 //其功能类似于find。 //这个函数使用一对迭代器和一个值做参数,返回这个值出现次数的统计结果。 //编写程序读取一系列int型数据,并将它们存储到vector对象中 //统计某个值出现了多少次 #include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { vector<int> ivec; int ival; int ival1; int cnt 阅读全文

posted @ 2012-03-01 17:05 1.曲待续 阅读(115) 评论(0) 推荐(0) 编辑

2012年2月26日

记录点滴1

摘要: 2012年2月20日 大学二年级第四学期始每周一记录第一周:2月20日~2月26日重要人物:巫大爷基本时间:除了吃喝拉撒睡的其余时间主要地点:教学楼、宿舍、饭堂、操场事件大概:电子工艺实习、在宿舍看《职来职往》求职节目、看《程序员羊皮卷》、继续学习《C++ Primer 第4版》、及时去饭堂吃饭、上学吃早餐麻烦、跟小钱和俊哥去操场跑步锻炼、玩微博、上csdn发表文章路过经过:上电子工艺实习课比较懒散,不认真并且应付了事每天看一集《职来职往》每天看一章《程序员羊皮卷》每天学习一点《C++ Primer》准时吃饭,但不按时睡觉,不早起、贪睡每天准时8:30左右出发去操场跑步收获结果:为期两周的电子 阅读全文

posted @ 2012-02-26 21:37 1.曲待续 阅读(149) 评论(0) 推荐(0) 编辑

2012年2月25日

C++ Primer 第10章 习题10.38

摘要: //10.28.cpp //建立作者及其作品的multimap容器 //以下的格式按姓名首字母的顺序输出作者及其作品: //Author Names Beginning with 'A' //Author,book,book,....... //Author Names Beginning with 'B' //... #include<iostream> #include<map> #include<string> using namespace std; int main() { multimap<string,st 阅读全文

posted @ 2012-02-25 20:09 1.曲待续 阅读(137) 评论(0) 推荐(0) 编辑

上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 31 下一页

导航