2020年团体程序设计天梯赛 L1-6 吃火锅
思路:
水题,略过
Tip:
这题我看好多人用的暴力,这里推荐一下string里的find函数,很方便
#include <bits/stdc++.h> using namespace std; int main() { string s; int n = 0; int num = 0; int indexx = 0; while (getline(cin, s) && s != ".") { n++; if (s.find("chi1 huo3 guo1") != string::npos) { if (num == 0) indexx = n; num++; } } cout << n << endl; if (num == 0) cout << "-_-#" << endl; else { cout << indexx << " " << num << endl; } return 0; }