C++ Primer(第五版)练习3.22
来源:互联网 发布:eureka服务注册源码 编辑:程序博客网 时间:2024/06/05 18:45
这题我遇到的一些不懂的地方:
先贴上能Debug的代码如下,这是参考网络上的写的
————————————————————————————————————————
#include <iostream>#include <string>#include <vector>using namespace std;int main(){string text = ("Hello,my name is YJ1an.Nice to meet you!");for (auto it = text.begin(); it != text.end(); ++it)*it = toupper(*it);cout << text << endl;system("pause");return 0;}
——————————————————————————————————————————
但我如果想用vector<string>定义 text,就会出现很多问题:(如下代码是有错误的)
#include <iostream>#include <string>#include <vector>using namespace std;int main(){vector<string> text;string word;while (cin >> word)text.push_back(word);for (auto it = text.begin(); it != text.end() && !it->empty(); ++it)*it = toupper(*it);for (auto i : text)cout << i << " ";system("pause");return 0;}
0 0
- c++primer第五版课后练习答案(第五章)
- C++ Primer(第五版)练习3.22
- c++primer第五版课后练习答案(第一章)
- c++primer第五版课后练习答案(第三章)
- c++primer第五版课后练习答案(第九章)
- c++primer第五版课后练习答案(第十章)
- c++primer第五版课后练习答案(第六章)
- C++Primer第五版 1.2节练习(解答)
- C++Primer第五版 练习11.3(解答)
- C++Primer第五版 练习11.4(解答)
- C++Primer第五版 练习11.7(解答)
- C++Primer第五版 练习11.8(解答)
- C++Primer第五版 练习11.9(解答)
- C++Primer第五版 练习11.10(解答)
- C++Primer第五版 练习11.11(解答)
- C++Primer第五版 11.2.3节练习(解答)
- C++Primer第五版 练习11.12(解答)
- C++Primer第五版 练习11.13(解答)
- 371.leetcode Sum of Two Integers(easy)[异或 与运算处理]
- jsp、servlet和tomcat的关系
- 新增linux账户来使用深度学习框架-caffe
- 题目1019:简单计算器
- 51Nod-扔盘子(O(n)解法)
- C++ Primer(第五版)练习3.22
- UOJ 147 & 151 [NOIP2015]斗地主
- 递归与尾递归(Tail Recursion)
- 【DP 训练】Cake Slicing, ACM/ICPC Nanjing 2007, UVa1629
- 数组的4个基本操作:找出最大元素、平均值、复制、反转。
- PHP 线程安全与非线程安全版本的区别深入解析
- Java的动态代理
- 求两个数的最大公约数
- hdoj5978Sequence I【kmp】