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/

全部评论

相关推荐

shtdbb_:还不错,没有让你做了笔试再挂你
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务