HDU_2026首字母变大写

来源:互联网 发布:淘宝店铺游戏专营 编辑:程序博客网 时间:2024/04/30 03:46
输入一个英文句子,将每个单词的第一个字母改成大写字母。
 

Input
输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行。
 

Output
请输出按照要求改写后的英文句子。
 

Sample Input
i like acmi want to get an accepted
 

Sample Output
I Like AcmI Want To Get An Accepted
 代码:
#include<iostream>#include<stdio.h>#include<string>#include<string.h>using namespace std;int main(){    char s[110];    int i;    while(gets(s))    {        int len = strlen(s);        s[0] = s[0] - 32;        printf("%c",s[0]);        for( i =1; i < len; i++)        {            if(s[i] == ' ')            {                s[i+1] = s[i+1] - 32;            }            printf("%c",s[i]);        }        printf("\n");    }    return 0;}


0 0
原创粉丝点击