- 博客(26)
- 收藏
- 关注
原创 C++ Primer课后练习12.2
//练习12.2#include#include #include #include #include #include using namespace std;class StrBlob {public: using size_type = vector::size_type; StrBlob() : data(std::make_shared>()) { cout
2017-02-20 20:36:49 239
原创 C++ Primer课后练习11.33-11.36
//练习11.33#include#include#include#include#include#includeusing namespace std;//函数buildmap读入给定文件,建立起转换映射map buildmap(ifstream & mapfile){ map trans_map; //保持转换规则 string key;
2017-02-15 13:58:35 224
原创 C++ Primer课后练习11.20,11.23,11.26,11.27,11.28,11.29,11.30,11.31,11.32
/*练习11.20*/#include#include#include#includeusing namespace std;int main(void){ map maper; string word; while (cin >> word) { auto ret = maper.insert(make_pair(word, 1)); if (!ret.second
2017-02-14 09:53:01 388
原创 C++ Primer课后练习11.3,11.4,11.7,11.8,11.11,11.12,11.13,11.14
//课后练习11.3&11.4#include#include#include#include#include#includeusing namespace std;int main(void){ map wordcount;//string到size_t的空map string word; while (cin >> word) { for (auto &
2017-01-07 16:26:15 301
原创 C++ Primer课后练习10.34~10.37,10.42
//练习10.34:使用reverse_iterator逆序打印一个vector#include#include#include#include#includeusing namespace std;int main(void){ vector vec; string ss; while (cin >> ss) { vec.push_back(ss); } for
2017-01-05 16:23:21 269
原创 C++ Primer课后练习10.29-10.33
//课后练习10.29#include#include#include#include#includeusing namespace std;int main(void){ ifstream in1("file1.txt"); ifstream in2("file2.txt"); istream_iterator in_iterator(in1),in_iterator1(i
2017-01-01 17:13:31 267
原创 C++ Primer课后练习10.27,10.28
//10.27 运行结果不大对#include#include#include#include#include#includeusing namespace std;int main(void){ vector list2; int v1; while (cin >> v1) { list2.push_back(v1); } list list1; uniqu
2016-12-29 20:26:43 280 2
原创 C++ Primer课后练习10.22,10.24,10.25
//课后练习10.22#include#include#include#include#include#includeusing namespace std;using namespace placeholders;void elimdups(vector & words){ //按字典序排序 sort(words.begin(), words.end()); auto
2016-12-23 21:01:46 186
原创 C++ Primer课后练习10.22,10.23,10.24,10.25
//课后练习10.22#include#include#include#include#include#includeusing namespace std;using namespace placeholders;void elimdups(vector & words){ //按字典序排序 sort(words.begin(), words.end()); auto
2016-12-23 20:11:29 235
原创 C++ Primer课后练习10.20,10.21
//课后练习10.20#include#include#include#include#includeusing namespace std;void elimdups(vector & words){ //按字典序排序 sort(words.begin(), words.end()); auto end_unique = unique(words.begin(), word
2016-12-20 20:02:30 263
原创 C++ Primer 课后练习10.16,10.17,10.18,10.19
#include#include#include#include#includeusing namespace std;void elimdups(vector & words){ //按字典序排序 sort(words.begin(), words.end()); auto end_unique = unique(words.begin(), words.end()); w
2016-12-19 15:14:49 250
原创 C++ Primer 课后练习10.11,10.12,10.13
课后练习10-11#include#include#include#include#includeusing namespace std;bool ishorter(const string &s1, const string & s2){ return s1.size() < s2.size();}void elimdups(vector & words){ //按字典
2016-12-16 20:01:50 330
原创 C++ Primer 课后练习10.1,10.2,10.3,10.4,10.5,10.7,10.9
练习10.1-10.2#include#include#include#includeusing namespace std;int main(void){ int ia[] = { 12, 24, 8, 12, 24, 8, 21, 45, 89, 12, 56, 56 }; int val = 24; int result = count(begin(ia), end(ia
2016-12-13 19:37:38 488
原创 C++ Primer课后练习9.52
9.52#include#include#include#includeusing namespace std;int main(void){ int biaozhi = 0; ifstream is("file1.txt"); ofstream os("file2.txt"); stack stack1; string word; string line; whil
2016-12-08 21:00:23 384
原创 C++ Primer 课后练习9.51
9.51#include#includeusing namespace std;string oops("0123456789");class time{public: time(const string & ss); friend void display(time & t);private: unsigned year; unsigned month; unsigne
2016-12-08 17:31:32 207
原创 C++ Primer 课后练习9.51
9.519.51设计一个类,他有三个unsigned成员,分别表示年,月和日,为其编写构造函数,接受一个表示日期的string参数,你的构造函数应该能处理不同的数据格式,如Januanry 1,1900 1/1/1900、Jane1 1900#include#includeusing namespace std;string oops("0123456789");class
2016-12-08 17:27:34 327
原创 C++ Primer 课后练习9.50
练习9.50 编写程序处理一个vector,其元素都表示整型值,计算vec所有元素之和。修改程序,使之计算表示浮点值的string之和#include#include#include#includeusing namespace std;int main(void){ ifstream is("file1.txt"); ifstream is1("file2.t
2016-12-08 11:33:55 257
原创 C++ Primer课后练习9.49
练习9.49,如果一个字母延伸到中线上,如d或f, 则称其上有出头部分(ascender).如果一个字母延伸到中线之下,如p或g,则其有下出头部分(descender)。编写程序。读入一个单次文件,输出最长的既不包含上出头部分,也不包含下出头部分的单词。#include#include#includeusing namespace std;int main(void){
2016-12-07 20:30:31 402
原创 C++ Primer课后练习9.47
9.47:编写程序,首先找string"ab2c3d7R4E6"中的每个数字字符,然后查找其中每个字母字符。编写两个版本的程序,第一个要使用find_first_of,第二个要使用find_first_not_of.#include#includeusing namespace std;int main(void){ string s1("ab2c3d7R4E6");
2016-12-07 18:51:55 202
原创 C++ Primer课后练习 9-46
练习9.46#include#includeusing namespace std;std::string oops_func(const string & s1, const string & before_s1, const string & after_s1);int main(void){ string s1 = "Rachel "; cout << "s
2016-12-06 20:30:09 187
原创 C++ Primer 课后练习9.45
练习9.45,编写一个函数,接受一个表示名字的string参数,和两个分别表示前缀和后缀的字符串添加到给定的名字中#include#includeusing namespace std;void oops_func(string & s1, const string & before_s1, const string & after_s1);int main(void)
2016-12-06 20:08:00 235
原创 C++ Primer 课后联系9.44
9.44#include#includeusing namespace std;void oops_func(string & s1,const string & s2,const string & s3);int main(void){ string s = "Rachel Monica Joey Chandler Phobe"; string newval =
2016-12-06 19:27:37 188
原创 基于EIA-232,的ModBus-ASCII协议,校验方式Lrc-8
#include "stm32f10x.h" u8 Rcv_Buffer[131]={0}; u8 Send_Buffer[131]={0};u16 Rcv_Index=0;u16 Send_Index=0;u8 Comu_Busy=0;u8 Sendcount=0; u8 Recivecount=0;u16 KAIGUANLIANG=0;ex
2016-12-06 19:11:49 432
原创 C++ primer课后练习9.43
练习9.43#include#includeusing namespace std;void oops_func(string & s1, string & s2, string & s3);int main(void){ string s = "Rachel Monica Monica Joey Chandler Phobe Monica"; string newv
2016-12-06 19:00:20 311
原创 c++ Primer课后练习9-31
练习9.31:第316页删除偶数值元素并复制奇数值元素的程序能不能用list或forward_list。为什么?修改程序,使之也能用于这种类型#include#include#include#includeusing namespace std;int main(void){ /*vector vec1 = { 0, 1, 2, 3, 4, 5, 6, 7, 8,
2016-12-05 15:18:30 312
原创 c++ primer 课后练习 9.28
#include#include#includeusing namespace std;void opps_func(forward_list & ,string, string);//我们要使用的函数int main(void){ forward_list flist = { "Andrew Wiggins", "Jabari Parker", "Joel Embii
2016-12-02 21:01:21 347
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人