zoukankan      html  css  js  c++  java
  • CF 281A Word Capitalization

    A. Word Capitalization
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard 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 exceed103.

    Output

    Output the given word after capitalization.

    Sample test(s)
    input
    ApPLe
    output
    ApPLe
    input
    konjac
    output
    Konjac

     1 #include <cstdio>
     2 #include <cstring>
     3 using namespace std;
     4 int main(void){
     5   char a[1000+10];
     6   int cnt = 0;
     7   while (~scanf("%s", a)){
     8     {
     9       int len = strlen(a); 
    10         if (a[0] >= 'a' && a[0] <= 'z') printf("%c", a[0]-32);
    11         else printf("%c", a[0]);
    12       for (int i = 1; i < len; ++i){ printf("%c", a[i]);
    13       }
    14       printf("\n");
    15     } cnt++;
    16   }
    17   return 0;
    18 }

    开始题目意思理解错了……WA了一次,这么简单的题目啊……

  • 相关阅读:
    CodeForces 697B Barnicle 模拟
    15.三数之和
    167.两数之和
    209.长度最小子数组-sliding window
    COMP9313 Week9a-0
    树总纲(To be continued)
    COMP9517 Week8
    COMP9313 week8b Pipeline
    94. 二叉树的中序遍历
    COMP9313 Week8 Classification and PySpark MLlib
  • 原文地址:https://www.cnblogs.com/liuxueyang/p/2954601.html
Copyright © 2011-2022 走看看