当前位置:网站首页>L1-070 吃火锅 (15 分)
L1-070 吃火锅 (15 分)
2022-04-22 22:19:00 【WTXYL】
这种天气你有什么破事打电话给我基本没用。但是如果你说“吃火锅”,那就厉害了,我们的故事就开始了。
本题要求你实现一个程序,自动检查你朋友给你发来的信息里有没有 chi1 huo3 guo1。
输入格式:
输入每行给出一句不超过 80 个字符的、以回车结尾的朋友信息,信息为非空字符串,仅包括字母、数字、空格、可见的半角标点符号。当读到某一行只有一个英文句点 . 时,输入结束,此行不算在朋友信息里。
输出格式:
首先在一行中输出朋友信息的总条数。然后对朋友的每一行信息,检查其中是否包含 chi1 huo3 guo1,并且统计这样厉害的信息有多少条。在第二行中首先输出第一次出现 chi1 huo3 guo1 的信息是第几条(从 1 开始计数),然后输出这类信息的总条数,其间以一个空格分隔。题目保证输出的所有数字不超过 100。
如果朋友从头到尾都没提 chi1 huo3 guo1 这个关键词,则在第二行输出一个表情 -_-#。
输入样例 1:
Hello!
are you there?
wantta chi1 huo3 guo1?
that's so li hai le
our story begins from chi1 huo3 guo1 le
.
输出样例 1:
5
3 2
输入样例 2:
Hello!
are you there?
wantta qi huo3 guo1 chi1huo3guo1?
that's so li hai le
our story begins from ci1 huo4 guo2 le
.
输出样例 2:
5
-_-#
代码:
#include <iostream>
#include <string>
using namespace std;
int main(){
int cnt = 0, firstP = -1, res = 0;
string s;
while(1){
getline(cin, s);
if(s.size() == 1 && s[0] == '.') break;
cnt ++;
if(s.find("chi1 huo3 guo1") != -1){
res ++;
if(firstP == -1) firstP = cnt;
}
}
cout << cnt << endl;
if(res == 0) cout << "-_-#" << endl;
else cout << firstP << " " << res << endl;
}
版权声明
本文为[WTXYL]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_46891900/article/details/124318615
边栏推荐
猜你喜欢

10万开发者涌入“酷应用”,钉钉押注场景化

做到与做好,国产引擎 Cocos 如何丛林突围?

动态规划:分组背包问题
![[summary of scattered knowledge points 5]](/img/a6/6700f00b01bc59fc0366d64071ac41.png)
[summary of scattered knowledge points 5]

Person re identification: past, present and future

行人重识别综述之Person Re-identification:Past, Present and Future

Steps to build appinventor2 on the window

RPC详解

appinventor拓展开发

GBase 8s V8. 8 SQL Guide: Tutorial - 6.2.1 (2)
随机推荐
Rasa课程、Rasa培训、Rasa面试、Rasa实战系列之Rasa全新全局词槽映射的 3 大方法
Multithreading advanced (7) -- optimistic lock and pessimistic lock
3.20-4.20 summary of recent project experience
最左匹配原则的原理
GBase 8s V8.8 SQL 指南:教程-6.2
Graph and numerical representation of knowledge map of knowledge representation
PMP证书到期了有必要续吗
ACL2022 | 利用中文语言层级异质图强化预训练语言模型
Rasa's new training method of Rasa
MySql--- 数据类型
Lecture recording and broadcasting | subgraph matching algorithm in graph database - Zou Lei
外部中断---------stm32f407zet6
MySQL表的增删改查(进阶)
[mmub] mobile phone user behavior modeling based on Hidden Markov Model -- hidden Markov model
O0 O1 O2 O3 optimization principle
repeat_map mp.find() + mp.erase()
创建动态链接库,头文件报错expected initializer before “function name“
餐饮行业收银系统源码,C# .NET + MSSQL WPF
根据这个有效方法,UI自动化测试就是那么的简单
动态规划:分组背包问题