<C++ Primer_5th>习题_3.22
来源:互联网 发布:ubuntu修改hosts翻墙 编辑:程序博客网 时间:2024/05/17 00:03
//修改之前的那个输出 text第一段程序,首先把text的第一段全部改写成大写形式,然后再输出它#include<iostream>#include<string>#include<vector>using namespace std;int main(){vector<string> text;string s;cout << "请输入一段字符串" << endl;//利用getline读取一句话,直接回车产生一个空串,表示段落结束while (getline(cin, s))text.push_back(s);//利用迭代器遍历全部字符串,遇到空串停止循环for (auto it = text.begin() ; it != text.end() && !it->empty() ; ++it ){//利用迭代器遍历当前字符串for (auto it2 = it->begin() ; it2 !=it->end() ;++it2 )*it2 = toupper(*it2 );//输出当前字符串cout << *it << endl;}system("pause");return 0;}
阅读全文
0 0
- <C++ Primer_5th>习题_3.22
- <C++ Primer_5th>习题_3.2
- <C++ Primer_5th>习题_3.3
- <C++ Primer_5th>习题_3.4
- <C++ Primer_5th>习题_3.5
- <C++ Primer_5th>习题_3.6
- <C++ Primer_5th>习题_3.10
- <C++ Primer_5th>习题_3.14
- <C++ Primer_5th>习题_3.16
- <C++ Primer_5th>习题_3.17
- <C++ Primer_5th>习题_3.20
- <C++ Primer_5th>习题_3.23
- <C++ Primer_5th>习题_3.24
- <C++ Primer_5th>习题_3.25
- <C++ Primer_5th>习题_3.31
- <C++ Primer_5th>习题_3.35
- <C++ Primer_5th>习题_3.36
- <C++ Primer_5th>习题_1.22
- <C++ Primer_5th>习题_3.20
- matlab基础(2)
- 汉诺塔(Hanoi)问题递归&非递归的C++实现及总结
- 十进制转十六进制的C实现
- 【HDU 1003】 Max Sum
- <C++ Primer_5th>习题_3.22
- 167. Two Sum II
- <C++ Primer_5th>习题_3.23
- Spring框架-第一弹
- ios-frame和bounds
- LinkList_Stack(链式栈)
- 第2篇 SercureCRT使用root远程登录ubuntu16.04
- <C++ Primer_5th>习题_3.24
- CodeForces