c++primer第五版 vector 练习

从cin读入一组词并把它们存入一个vector对象,然后设法把所有词都改写为大写形式。

源代码:



#include <iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	vector<string>s;
	string n;
	while (cin >> n) {
		s.push_back(n);//字符压入容器
		for (auto num : s) {//遍历容器
			for (auto &c:num) {
				c = toupper(c);//toipper(转换为大写字符)
				cout << c << endl;
			}
			

		}
		
	}
	system("pause");
	return 0;
	
}
	
	
	

发布了2 篇原创文章 · 获赞 0 · 访问量 23

猜你喜欢

转载自blog.csdn.net/weixin_45858760/article/details/104080818