首字母变大写
Total Submission(s): 53641 Accepted Submission(s): 29475
Problem 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
Author
lcy
Source
#include <stdio.h>
int main()
{
char c;
int i = 0;
while ((c = getchar()) != EOF)
{
if (c == ' ')
{
printf(" ");
i = 0;
continue;
}
if (c == '\n')
{
printf("\n");
i = 0;
continue;
}
if (i == 0)
{
printf("%c", c - 32);
++i;
}
else printf("%c", c);
}
return 0;
}
本文介绍了一个简单的程序设计问题——如何将输入的英文句子中每个单词的首字母转换为大写。通过示例展示了输入输出样例,并提供了一段C语言代码实现该功能。
9万+

被折叠的 条评论
为什么被折叠?



