基本思想:
其实如果只有空格完全可以stringstream来做;
关键点:
无;
#include<iostream> #include<vector> #include<string> #include<sstream> using namespace std; int main() { string s; while (getline(cin, s)) { if (s[0] >= ‘a‘&&s[0] <= ‘z‘) s[0] = ‘A‘ + (s[0] - ‘a‘); for (int i = 0; i < s.size(); i++) { if (s[i] == ‘\t‘ || s[i] == ‘ ‘ || s[i] == ‘\r‘ || s[i] == ‘\n‘) { if (s[i + 1] >= ‘a‘&&s[i + 1] <= ‘z‘) s[i + 1] = ‘A‘ + (s[i + 1] - ‘a‘); } } cout << s << endl; } }
原文地址:https://www.cnblogs.com/songlinxuan/p/12459914.html
时间: 2024-11-13 23:31:35