cin输入流,空格隔开每个变量,回车接收,ctrl+z结束!

 

/*********************************
*********************************/
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
using namespace std;

int main()
{
	vector<string> text;
	string textVal;

	/*输入单词,空格隔开,回车接收,ctrl+z结束。*/
	while (cin >> textVal) {
		text.push_back(textVal);
	}

	for (vector<string>::size_type ix=0; ix!=text.size(); ix++) {
		/*text[ix]对应单词*/
		for (string::size_type iy=0; iy!=text[ix].size(); iy++) {
			/*text[ix][iy]对应单词中的字母*/
			if (islower(text[ix][iy])) {
				text[ix][iy] = toupper(text[ix][iy]);
			}
		}
		cout << text[ix] << " ";
	}

	return 0;
}


 


 

控制台输入输出

每个单词存储为一个vector对象,将单词中的小写字母变成大写

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-31
  • 2021-12-17
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案