您的位置:首页 > 其它

题目1121:首字母大写

2017-04-18 10:27 183 查看

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;
//1121
char s[110];
void toUpper(char *c){
    if(*c>='a'&&*c<='z')
        *c=*c-'a'+'A';
}
int main(){
    //freopen("input.txt","r",stdin);
    while(gets(s)!=NULL){
        for(int i=0;i<strlen(s);i++){
            if(i==0) toUpper(&s[i]);
            else if(s[i-1]==' '||s[i-1]=='\t'||s[i-1]=='\r')
                    toUpper(&s[i]);
        }
        printf("%s\n",s);
    }
    return 0;
}
/**************************************************************
    Problem: 1121
    User: cust123
    Language: C++
    Result: Accepted
    Time:0 ms
    Memory:1520 kb
****************************************************************/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: