HDU2026 首字母变大写

此题要注意的是,输入输出要用gets和puts,因为scanf得到的字符串不包含空格,而且在句子最后不易输出换行符

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <stdio.h>
#include <string.h>
int main()
{
	char str[101],i;
	while(gets(str)!='')
	{
		str[0]=str[0]-32;
		for(i=0;str[i];i++)//空字符是assic值为0 
		{
			if(str[i]==' ') str[i+1]-=32;
		}
        puts(str);//输出后会自动换行 
	}
	return 0;
}

原文地址:https://www.cnblogs.com/cnlik/p/11851910.html