-
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.
-
#include <iostream> #include <string.h> #include <stdlib.h> #include <stdio.h>using namespace Std;char Str[100];int Main () {while (gets (str) = NULL) {int len = strlen (str); if (str[0] >= && str[0] <= 122) {str[0]-= 32; } for (int i=1; i<len; i++) {if (str[i] = = ' | | str[i] = = ' \ t ' | | str[i]== ' \ r ' | | str[i] = = ' \ n ') {if (str[i+1] >= && str[i+1] <= 122) {s TR[I+1]-= 32; }}} cout<<str<<endl; } return 0; }/************************************************************** problem:1121 User:carvin language:c++ Resu lt:accepted time:10 Ms Memory:1520 kb****************************************************************/
-
Title 1121: Capitalize first letter