题解 | #简单错误记录#

简单错误记录

https://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb

#include <iostream>
#include <map>
#include <cstring>
#include <vector>
#include <cmath>
using namespace std;
static int cnt=0;
int deal_name(string str,string num,vector<vector<string>> &q,vector<string> &l)
{
    int n;
    for(int i=0;i<q.size();i++){
        if(str == q[i][0] && num == q[i][1]){
            n=atoi(q[i][2].c_str());
            n=n+1;
           q[i][2] = to_string(n);
           //cout << q[i][0] << q[i][1] << q[i][2] << "@@@" << endl;
           //cout << q[i][0] << str << "@@@" << endl;
           return 0;
        }
    }
    l.push_back(str);
    l.push_back(num);
    l.push_back(to_string(1));
    q.push_back(l);
    l.clear();
   //cout << str << "@@@" << endl;
    return 0;
}

int action(string str,string &name,string &num)
{
    int i;
    string s;
    //cout << str << endl;
    for(i=0;i<str.size();i++){
        s = s+str[i];
        //cout << s << endl;
        if(str[i] == '\\'){
            //cout << "------" << endl;
            s ="";
        }
        if(str[i] == ' '){
            name = s;
            //cout << name << endl;
            s ="";
        }
        if(i == str.size()-1){
            num =s;
            //cout << s << endl;
        }
    }
    //cout << name << "    &&&&&   " << num << endl;
    return 0;
}

int cut_name(string &name)
{
    if(name.size() > 16){
        name = name.substr(name.size()-17,name.size());   
    }
   //cout << name << name.size() << endl;
    return 0;
}

int deal_string(string str,vector<vector<string>> &q,vector<string> &l)
{
    int a;int b;
    string name;
    string num;
    int n;
    action(str,name,num);
    cut_name(name);
    deal_name(name,num,q,l);
    return 0;
}

int main() {
    string str;
    vector<string> k;
    vector<string> l;
    vector<string> t;
    vector<vector<string>> q;
    while(getline(cin,str)){
        k.push_back(str);
    }

    for(auto e : k){
        deal_string(e,q,l);
    }
    int ct;
    if(q.size() > 8){
        ct =8;
    }else{
        ct=q.size();
    }
    for(int i=q.size()-ct;i<q.size();i++){
        cout << q[i][0] << "" << q[i][1] << " " << q[i][2] << endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

叶扰云倾:进度更新,现在阿里云面完3面了,感觉3面答得还行,基本都答上了,自己熟悉的地方也说的比较细致,但感觉面试官有点心不在焉不知道是不是不想要我了,求阿里收留,我直接秒到岗当阿里孝子,学校那边的房子都退租了,下学期都不回学校,全职猛猛实习半年。这种条件还不诱人吗难道 然后现在约到了字节的一面和淘天的复活赛,外加猿辅导。华为笔试完没动静。 美团那边之前投了个base广州的,把我流程卡麻了,应该是不怎么招人,我直接简历挂了,现在进了一个正常的后端流程,还在筛选,不知道还有没有hc。
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-09 12:10
直接上图
牛客13578115...:改得一般,不值80
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务