Hangzhou Electric Oj brush title (2026)

Change the first letter capitalized

Subject description:

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

By the answer:

#include <stdio.h>
#include<string.h>       
int main()
{
	char str[100];
	int i,len;
	while(gets(str)){             //gets从标准输入设备读字符串函数
	    len=strlen(str);          //每个字符串长度 
	    str[0]-=32;
	    for(i=1;i<len;i++){
			if(str[i-1]==' '){
				str[i]-=32;       //小写转换为大写 
			}
		}
	    printf("%s\n",str);      //注意!
	     
	}
	return 0;
}

 

Published 55 original articles · won praise 0 · Views 1013

Guess you like

Origin blog.csdn.net/ZhangShaoYan111/article/details/104145611