纪念下第一道TC题。。。那格式实在很蛋疼,很不习惯Problem Statement | |||||||||||||
| You are given a simple paragraph containing a number of sentences, the original person who wrote the paragraph was in a rush and used only lower case letters ('a'-'z') for the words in the paragraph and did not use any punctuation other than a period to separate sentences. Your task is to fix the capitalization in the paragraph, the objective is to make it so every sentence in the paragraph begins with a capital (upper case) letter ('A'-'Z'). The paragraph is formatted as one or more sentences separated by single space (' ') characters. Each sentence consists of one or more words separated by single space (' ') characters. The last word in a sentence is always immediately followed by a single dot ('.') character. Each word is a non-empty string containing only lower case letters ('a'-'z'). As an example, consider the following paragraph (quotes for clarity): "this is merely an example. be careful. this is a new sentence." The result of your program must then be as follows: "This is merely an example. Be careful. This is a new sentence." | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
| - | paragraph will contain between 2 and 50 characters, inclusive. | ||||||||||||
| - | Each character in paragraph will be a lower case letter ('a'-'z'), a space (' ') or a dot ('.'). | ||||||||||||
| - | The first character of paragraph will be a lower case letter ('a'-'z'). | ||||||||||||
| - | The last character of paragraph will be a dot ('.'). | ||||||||||||
| - | There will be no two consecutive space characters in paragraph. | ||||||||||||
| - | Every space (' ') character in paragraph will precede a letter. | ||||||||||||
| - | Every '.' character in paragraph except the last one will precede a space character. | ||||||||||||
Examples | |||||||||||||
| 0) | |||||||||||||
| |||||||||||||
| 1) | |||||||||||||
| |||||||||||||
| 2) | |||||||||||||
| |||||||||||||
| 3) | |||||||||||||
| |||||||||||||
本文介绍了一个简单的编程任务:将一段没有正确使用大小写的英文文本进行修正,确保每个句子的首字母都为大写。该任务涉及到字符串操作和基本的文本处理技巧。
892

被折叠的 条评论
为什么被折叠?



