#C5437. Count Sentences in a Text
Count Sentences in a Text
Count Sentences in a Text
Given a block of text, your task is to count the number of sentences it contains. A sentence is defined as any portion of text ending with one of the punctuation marks: .
, !
, or ?
. Note that sentences can be separated by these punctuation symbols, regardless of spacing.
For instance, the text:
Hello! How are you? I'm good.
contains three sentences.
Your program should read the text from standard input and output the number of sentences to standard output.
Mathematically, if we denote the text as a sequence of characters \(T = t_1 t_2 \ldots t_n\), then the number of sentences \(S\) is given by:
\[ S = \sum_{i=1}^{n} \mathbf{1}_{\{t_i \in \{'.', '!', '?'\}\}} \]
inputFormat
The input consists of a block of text which may span multiple lines. The text is provided via standard input.
outputFormat
Output a single integer that represents the number of sentences in the input text. The output should be printed to standard output.
## sampleHello.
1