您的位置:首页 > 其它

HDOJ 2026 首字母变大写

2017-05-20 19:32 302 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2026

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

题解

#include <stdio.h>
#include <ctype.h>
int main() {
char t[128] = {' '};
while (gets(t+1)) {
for (int i = 1; t[i]; i++)
putchar((isalpha(t[i])&&t[i-1]==' ') ? toupper(t[i]) : t[i]);
putchar('\n');
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: