题解 | #简单错误记录#
简单错误记录
https://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main() {
string s;
vector<string> strs;
map<string,int> mp;
while (getline(cin,s)) {
string tmp="";
for(auto i:s){
if(i=='\\'){
tmp="";
}else{
tmp+=i;
}
}
string t = tmp;
int j;
for(j = 0;j<t.size()&&t[j]!=' ';j++) ;
j = j>16?j-16:0;
tmp = tmp.substr(j);
if(mp.find(tmp)==mp.end()){
mp[tmp] = 1;
strs.push_back(tmp);
}else{
mp[tmp]++;
}
}
int begin = strs.size()>8?strs.size()-8:0;
for(int i = begin;i<strs.size();i++){
cout<<strs[i]<<" "<<mp[strs[i]]<<endl;
}
}
// 64 位输出请用 printf("%lld")
这。。。
