//这道题很水,但是我想挑战一下用字符串写,这里用get()也可以,注意必须读入空格,至于t是什么?为了过题设没有实际用途,t之后还有一个回车记得省略掉哦,我用的是vs用不了万能头。放代码!!!
#include <string>//你好呀
#include <iostream>
using namespace std;
int main() {
int m = 0, n = 0, i, j = 0, cnt1 = 0, cnt2 = 0, cnt3 = 0,t;
string s;
cin >> t;
cin.ignore(); // 忽略回车字符
getline(cin, s);
s = " "+s+" ";
if (s.find(" 1 ") != string::npos) {
m = s.find(" 1 ");
//cnt1++;
}
while (m != string::npos) {
m = s.find(" 1 ", m + 1);
cnt1++;
}
if (s.find(" 5 ") != string::npos) {
n = s.find(" 5 ");
// cnt2++;
}
while (n != string::npos) {
n = s.find(" 5 ", n + 1);
cnt2++;
}
if (s.find(" 10 ") != string::npos) {
j = s.find(" 10 ");
//cnt3++;
}
while (j != string::npos) {
j = s.find(" 10 ", j + 1);
cnt3++;
}
cout << cnt1 << " " << cnt2 << " " << cnt3;
return 0;
}
//本蒟蒻写的题解仅供参考,切勿抄袭,祝愿每个宝宝都能AK