[Explanations] - hdu change the first letter capitalized

## changed the first letter capitalized

Enter an English sentence, the first letter of each word into uppercase letters.

####Input

Input data comprising a plurality of test cases, each test case is a length not exceeding 100 English sentence, per line.

####Output

Please rewrite the output in accordance with the requirements of the English sentence.

####Sample Input

i like acm
i want to get an accepted

####Sample Output

I Like Acm
I Want To Get An Accepted

#### AC Code

#include <stdio.h>
#include <string.h>
int main(void)
{
    char arr[105];
    int i;
    while(gets(arr)){
        arr[0] -= 32;
        for(i = 1; i < strlen(arr); i ++){
            if(arr[i - 1] == ' '){
                arr[i] -= 32;
            }
        }
        printf("%s\n",arr);
    }
    return 0;
}

annotation

Note that the input is written while (gets (arr)) instead of while (gets (arr)! = EOF)

Published 34 original articles · won praise 2 · Views 936

Guess you like

Origin blog.csdn.net/Kapo1/article/details/103480862