【C++ Primer】【练习题】【3.14】将vector<string>对象各元素中的小写字母转换成大写字母
来源:互联网 发布:sql语句去掉重复数据 编辑:程序博客网 时间:2024/05/29 08:07
要求:读一组单词到vector<string>对象,将对象各元素中的小写字母转换成大写字母并输出。
#include <iostream>#include <vector>#include <string>#include <cctype>using namespace std;int main(){ vector<string> svec; string str; cout << "Please input text(EOF to end): "; while (cin >> str) { svec.push_back(str); } if (svec.size() == 0) { cout << "No text input!" << endl; return 0; } cout << "The output words are: " << endl; // 将元素中的小写字母转换成大写字母 for (vector<string>::size_type i = 0; i < svec.size(); i++) { for (string::size_type j = 0; j < svec[i].size(); j++) { if (islower(svec[i][j])) { svec[i][j] = toupper(svec[i][j]); } } cout << svec[i] << " "; if ((i + 1) % 8 == 0) { cout << endl; } } cout << endl; return 0;}
[chapter3]$ ./a.out Please input text(EOF to end): No text input! [chapter3]$ ./a.out Please input text(EOF to end): a B c D e F g The output words are: A B C D E F G [chapter3]$ ./a.out Please input text(EOF to end): a B c D e F g H i J k L m N o P q R s T u V w X y Z The output words are: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 0
- 【C++ Primer】【练习题】【3.14】将vector<string>对象各元素中的小写字母转换成大写字母
- c将大写字母转换成小写字母
- noi-8175-将字符串中的小写字母转换成大写字母
- 13:将字符串中的小写字母转换成大写字母
- 将字符串中的小写字母转换成大写字母
- 13.将字符串中的小写字母转换成大写字母
- 将大写字母转换成小写字母
- 将大写字母转换成小写字母
- 将小写字母转换成大写字母
- c语言从键盘中输入一串字符串,将字符中的大写转化成小写字母,将小写字母转换成大写字母,以*号键结束
- 编译器练习:将C程序中的注释中的小写字母转换为大写字母
- C语言toupper()函数:将小写字母转换为大写字母
- c语言将小写字母转换为大写字母
- C/C++之将串中的小写字母转换为大写字母
- 小写字母转换成大写字母
- 小写字母转换成大写字母
- 大写字母转换成小写字母
- 大写字母转换成小写字母
- 零基础HTML5游戏制作教程 第1章
- [Intel汇编-MASM]转移指令
- android listview无限循环显示数据
- hihocoder 1080 更为复杂的买卖房屋姿势(线段树经典操作,区间修改,add+set标记)
- 进制转换_C_杭电ACM2031
- 【C++ Primer】【练习题】【3.14】将vector<string>对象各元素中的小写字母转换成大写字母
- 搞ACM的你伤不起(已笑尿)(转)
- 大华股份地方就会更加地方疯疯癫癫
- 说的话发生的会感受到地方鬼地方
- JNI jstring
- Linux下ps aux命令 与 查看CPU配置
- 去哪儿网客服电话是多少
- hdu1241 简单搜索dfs
- 新的苹果应用提交心得(更新提交)