300773: CF147A. Punctuation

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Punctuation

题意翻译

## 题目描述 有一个文本,包含小写字母、空格和标点(点、逗号、感叹号和问号),连续的字母组成的序列称为单词。 你的任务是修改这个文本,使它满足一下规则: 1. 相邻两个单词间最多只能有一个空格 2. 标点的前面没有空格,后面有一个空格 (保证两个标点间至少有一个单词,文本的开头、结尾都是字母) ## 输入输出格式 ### 输入格式 一行非空字符串,不大于10000个字符 ### 输出格式 按照规则编辑好的字符串,末尾不能有多余的空格(可以有换行符)

题目描述

You are given a text that consists of lowercase Latin letters, spaces and punctuation marks (dot, comma, exclamation mark and question mark). A word is defined as a sequence of consecutive Latin letters. Your task is to add spaces to the text by the following rules: - if there is no punctuation mark between two words, then they should be separated by exactly one space - there should be no spaces before each punctuation mark - there should be exactly one space after each punctuation mark It is guaranteed that there is at least one word between any two punctuation marks. The text begins and ends with a Latin letter.

输入输出格式

输入格式


The input data contains of a single non-empty line — the text whose length is no more than 10000 characters.

输出格式


Print the text, edited according to the rules. In this problem you should follow the output format very strictly. For example, extra space at the end of the output line is considered as wrong answer. Note that a newline character at the end of the line doesn't matter.

输入输出样例

输入样例 #1

galileo galilei was an   italian physicist  ,mathematician,astronomer

输出样例 #1

galileo galilei was an italian physicist, mathematician, astronomer

输入样例 #2

galileo  was  born  in  pisa

输出样例 #2

galileo was born in pisa

Input

题意翻译

## 题目描述 有一个文本,包含小写字母、空格和标点(点、逗号、感叹号和问号),连续的字母组成的序列称为单词。 你的任务是修改这个文本,使它满足一下规则: 1. 相邻两个单词间最多只能有一个空格 2. 标点的前面没有空格,后面有一个空格 (保证两个标点间至少有一个单词,文本的开头、结尾都是字母) ## 输入输出格式 ### 输入格式 一行非空字符串,不大于10000个字符 ### 输出格式 按照规则编辑好的字符串,末尾不能有多余的空格(可以有换行符)

加入题单

算法标签: