-
Title Description:
-
For all words in a string, if the first letter of the word is not an uppercase letter, the first letter of the word becomes uppercase.
In the string, the words are separated by a white space character, including a space ('), a tab (' \ t '), a carriage return (' \ R '), and a newline character (' \ n ').
-
Input:
-
Enter a line: the string to be processed (less than 100 in length).
-
Output:
-
There may be multiple sets of test data, for each set of data,
Output one line: the converted string.
-
Sample input:
-
If so, you already has a Google account. You can sign in to the right.
-
Sample output:
-
If So, you already has A Google account. You Can sign in to the right.
-
Source:
- 2008 the computer research of the graphics Laboratory of Peking University The real problem
#include <iostream>#include<cstring>using namespacestd;intMain () {strings; while(Getline (cin,s)) {if(s[0]<='Z'&& s[0]>='a') s[0]=s[0]- +; for(intI=1; I<s.size (); i++){ if(s[i]==' '|| s[i]=='\ t'|| s[i]=='\ r'|| s[i]=='\ n'){ if(s[i+1]<='Z'&& s[1+i]>='a') s[1+i]=s[i+1]- +; }} cout<<s<<Endl; } return 0;}
1121. Capitalize first letter