CF 281A Word Capitalization
March 11, 2013
CodeForces
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
#include <cstdio>
#include <cstring>
using namespace std;
int main(void){
char a[1000+10];
int cnt = 0;
while (~scanf("%s", a)){
{
int len = strlen(a);
if (a[0] >= 'a' && a[0] <= 'z') printf("%c", a[0]-32);
else printf("%c", a[0]);
for (int i = 1; i < len; ++i){ printf("%c", a[i]);
}
printf("\n");
} cnt++;
}
return 0;
}
开始题目意思理解错了……WA了一次,这么简单的题目啊……