Description
对一个字符串中的所有单词,如果单词的首字母不是大写字母,则把单词的首字母变成大写字母。
在字符串中,单词之间通过空白符分隔,空白符包括:空格(' ')、制表符('\t')、回车符('\r')、换行符('\n')。
Input
输入一行:待处理的字符串(长度小于100)。
Output
可能有多组测试数据,对于每组数据,
输出一行:转换后的字符串。
Sample Input
if so, you already have a google account. you can sign in on the right.
Sample Output
If So, You Already Have A Google Account. You Can Sign In On The Right.
跟前面说反话的题目类似,只是最后加了一个首字母比较,要注意的是不能使用scanf函数,它会识别空格和换行为一个字符串的结束,所以使用gets()函数
#include<cstdio>
#include<cstring>
int main(){
char str[100];//存储整个字符串
while(gets(str)){//多组测试数据
int len=strlen(str);
char ans[100][100]={};//ans数组存储存储非空白符字符串,要初始化,而且要放在while循环里面