编程介的小学生 2017-02-26 08:13 采纳率: 20.5%
浏览 1067
已采纳

Finding a Word in a Text

Find out whether a given text file contains a given word W.

If the word W exists in the file, place in the output file the line number and the position in the line number of the last entry of the word. Otherwise place two numbers: 0 0. During text analysis do not take into consideration word carry-over, that is, the sought for word may begin on one line and end on another. The text may as well contain empty lines, which are also numbered, but must not be taken into account in searching for the word W.

Length (L) of the word W complies with the condition: 0 < L <= 255.

Length (S) of the lines of the input file complies with the condition: 0 <= S <= 255.

The number of lines in the input file does not exceed 100000.

The input text may contain any symbols in the range of 32..255. The input text does NOT contain any other symbols.

Input

The first line of the input file contains the word W. A word here is understood as a non-empty sequence of symbols. The second line contains the number of lines to follow. Beginning with the third(!) line the text, consisting of one or more lines (maybe empty), goes.

Process to the end of file.

Output

The output numbers must be separated by one space.

Sample Input

Word
5
Word

www W

orddd

Sample Output

3 5

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-03-03 21:15
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突