拜托详细的解释和过程

Description
输入一个英文句子,将每个单词的第一个字母改成大写字母。
Input
输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行。
Output
请输出按照要求改写后的英文句子。
Sample Input
i like acm
i want to get an accepted
Sample Output
I Like Acm
I Want To Get An Accepted

#include
void main()
{
char x[100];
int i;
printf("请输入英语句子\n");
gets(x);
x[0]=x[0]-32;
for (i=1;x[i]!='\0';i++)
{
if (x[i-1]==' ')
{
x[i]=x[i]-32;
}
}
for (i=0;x[i]!='\0';i++)
{
printf("%c",x[i]);
}
printf("\n");
}


 #include <stdio.h>  
int main()  
{  
    int i;  
    int word;  
    char str[200];  
    printf("请输入字符串:");  
    while(gets(str)!=NULL)  
    {  
        printf("修改后的字符串为:");  
        word=0;  
        for(i=0;str[i]!='\0';i++)  
        {  
            if(str[i]==' ')  
            {  
                word=0;  
                printf(" ");  
            }  
            else if(word==0)  
            {  
                word=1;  
                str[i]=str[i]-32;  
                printf("%c",str[i]);  
            }  
            else  
                printf("%c",str[i]);  
        }  
        printf("\n");  
    }  
    return 0;  
} 

图片说明

图片说明`