281A. Word Capitalization

281A. Word Capitalization

281A. Word Capitalization

  • time limit per test2 seconds
  • memory limit per test256 megabytes
  • inputstandard input
  • outputstandard output

Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.

大写是将单词的第一个字母写成大写字母。你的任务是将给定的单词大写。

Note, that during capitalization all the letters except the first one remains unchanged.

请注意,在大写期间,除第一个字母外,所有字母都保持不变。

Input

A single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The length of the word will not exceed 103.

Output

Output the given word after capitalization.

Examples
input1

ApPLe

output1

ApPLe

input2

konjac

output2

Konjac

Solution

islower(str[0])确认首字母是否小写,若是,用toupper(str[0])改写成大写字母

需要调用cctype

Code
#include <iostream>
using namespace std;

//281A. Word Capitalization
#include <cctype>
int main() {
    string str;
    cin >> str;
    if(islower(str[0])){
       str[0] = toupper(str[0]);
    }
    cout << str << endl;
}
CodeForces 文章被收录于专栏

https://codeforces.ml/

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-16 18:05
何尝不是一种学历歧视呢
下午吃泡馍:这种公司不投也罢,不过建议挂出公司名字,1.1w就应激到问是不是清北也是看得出来不是啥好公司了,估计这hr也没见过啥世面
点赞 评论 收藏
分享
自学java狠狠赚一...:骗你点star的,港卵公司,记得把star收回去
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务