hdu_2026_字母变大写

来源:互联网 发布:穆大叔生涯数据 编辑:程序博客网 时间:2024/04/30 03:30

刷.....

http://acm.hdu.edu.cn/showproblem.php?pid=2026

字母变大写

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 13358    Accepted Submission(s): 7358


Problem Description
输入一个英文句子,将每个单词的第一个字母改成大写字母。
 

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

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

Sample Input
i like acmi want to get an accepted
 

Sample Output
I Like AcmI Want To Get An Accepted
 
        1. #include<iostream>
        2. using namespace std;
        3. int main()
        4. {
        5. char str[101];
        6. int i;
        7. while(cin.getline(str,100))
        8. {
        9. cout<<(char)(str[0]-'a'+'A');
        10. for(i=1;str[i]!='\0';i++)
        11. {
        12. if(str[i-1]==' ')
        13. cout<<(char)(str[i]-'a'+'A');
        14. else
        15. cout<<str[i];
        16. }
        17. cout<<"\n";
        18. }
        19. return 0;
        20. }

原创粉丝点击