利用getline来处理一整行的输入
#include<iostream>
#include<string>
using namespace std;

int main() {
	string str;
	while (getline(cin,str) )
	{
		if (str[0] >= 'a' && str[0] <= 'z') 
			str[0] = str[0] + 'A' - 'a';
		for (int i = 0; i < str.length(); i++) 
		{

			if ((str[i] == ' '||str[i]=='\t'||str[i]=='\r'||str[i]=='\n' )&& (str[i + 1] >= 'a' && str[i + 1] <= 'z')) {
				str[i + 1] += 'A' - 'a';
			}

		}
		cout << str << endl;
	}

}