题解 | #首字母大写#
首字母大写
http://www.nowcoder.com/practice/91f9c70e7b6f4c0ab23744055632467a
easy
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str,temp;
while (getline(cin, str)) {
for (int i = 0,j,flag; i < str.size(); ) {
for (j = i,flag = 0; (str[j] >= 'a' && str[j] <= 'z') ||
(str[j] >= 'A' && str[j] <= 'Z') || (str[j] >= '0' && str[j] <= '9');++j) {
flag = 1;
if (j == i)
cout << char(toupper(str[j]));
else
cout << str[j];
}
if (flag)
i = j;
else
cout << str[i++];
}
}
}