-->
当前位置:首页 > 题库

PROGRAMMING:Count the number of words

Luz5年前 (2021-05-10)题库453
###Task description
```
General text editors have the function of finding words, which can quickly locate the position of specific words in the article, and some can also count the number of specific words in the article.
Now, please program to achieve this function, the specific requirements are: given a word, please output the number of times it appears in a given article and the first position. Note: when matching words, they are not case sensitive, but they must be completely matched, that is, the given word must be exactly the same as an independent word in the article without case sensitivity (see example 1). If the given word is only a part of a word in the article, it is not a match (see example 2).
```
###Input format:
```
Two lines.
The first line is a string containing only letters, which represents a given word;
The second line is a string that can contain only letters and spaces to represent a given article.
```
###Output format:
```
There is only one line. If a given word is found in the article, two integers will be output. The two integers are separated by a space, which are the number of times the word appears in the article and the position of the first occurrence (that is, the position of the first letter of the word in the article when it first appears in the article, starting from 0); If the word does not appear in the article, then directly output an integer - 1.
```
###Input sample 1:
```in
To
to be or not to be is a question
```
###Output sample 1:
```out
2 0
```
###Input sample 2:
```in
to
Did the Ottoman Empire lose its power at that time
```
###Output sample 2:
```out
-1
```
###Title Source
The second question of the popularization group in the second round of noip 2011.
This topic is selected from openjudge website http://noi.openjudge.cn/ch0112/05/







answer:If there is no answer, please comment