V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
angelcstt
V2EX  ›  程序员

各位大佬帮忙做个菊花的笔试题,感谢

  •  
  •   angelcstt · 2019-08-07 19:26:08 +08:00 · 3276 次点击
    这是一个创建于 1694 天前的主题,其中的信息可能已经有所发展或是发生改变。

    RT

    https://i.loli.net/2019/08/07/gS95mI8nbZBX4ha.jpg

    感谢

    18 条回复    2019-08-08 11:17:37 +08:00
    angelcstt
        1
    angelcstt  
    OP
       2019-08-07 19:35:30 +08:00
    大佬在哪里 求助大佬啊 有偿都可以
    msaionyc
        3
    msaionyc  
       2019-08-07 19:38:44 +08:00
    你题目给完整了吗
    angelcstt
        4
    angelcstt  
    OP
       2019-08-07 19:39:22 +08:00
    @msaionyc 大佬等我拍完整
    wateryessence
        5
    wateryessence  
       2019-08-07 19:40:08 +08:00
    牛客网问去
    angelcstt
        6
    angelcstt  
    OP
       2019-08-07 19:49:04 +08:00
    第一题 @msaionyc ~

    https://i.loli.net (外链)/2019/08/07/gS95mI8nbZBX4ha.jpg
    https://imgchr.com/i/eII5 (外链) GT
    lxy42
        7
    lxy42  
       2019-08-07 19:50:32 +08:00 via Android
    第一题没拍全吧,估计考查的是中缀后缀表达式。
    angelcstt
        8
    angelcstt  
    OP
       2019-08-07 19:51:56 +08:00 via iPhone
    @lxy42 第一题下面补充了大佬
    brainfxxk
        9
    brainfxxk  
       2019-08-07 20:10:22 +08:00
    第一个表达式求值 第二个字符串处理...
    lxy42
        10
    lxy42  
       2019-08-07 20:46:36 +08:00 via Android
    第二题用一个长度为 26 的数组表示字符集,数组元素值等于对应字符的个数。两个数组相减就是结果。
    Leigg
        11
    Leigg  
       2019-08-07 21:02:54 +08:00 via Android
    能不能换个图床,这个很渣
    angelcstt
        12
    angelcstt  
    OP
       2019-08-07 21:04:46 +08:00 via iPhone
    @Leigg 提交了,谢谢啦
    angelcstt
        13
    angelcstt  
    OP
       2019-08-07 21:04:53 +08:00 via iPhone
    @lxy42 谢谢啦
    wangkai0351
        14
    wangkai0351  
       2019-08-07 21:11:29 +08:00
    #include <iostream>
    #include <string>
    #include <map>
    #include <vector>
    #include <sstream>
    #include <string.h>
    using namespace std;

    vector<string> split(const string &str,const string &pattern)
    {
    //const char* convert to char*
    char * strc = new char[strlen(str.c_str())+1];
    strcpy(strc, str.c_str());
    vector<string> resultVec;
    char* tmpStr = strtok(strc, pattern.c_str());
    while (tmpStr != NULL)
    {
    resultVec.push_back(string(tmpStr));
    tmpStr = strtok(NULL, pattern.c_str());
    }

    delete[] strc;

    return resultVec;
    }

    int main(void)
    {
    string s;
    while(cin>>s)
    {
    string s1;
    string s2;
    size_t at_pos = s.find('@');
    //cout << "at_pos = " << at_pos << endl;
    if(at_pos == s.size()-1)
    {
    for (int i = 0; i < s.size()-1; ++i) {
    cout << s[i];
    }
    cout << endl;
    break;
    }
    else
    {
    s1 = s.substr(0,at_pos);
    s2 = s.substr(at_pos+1,s.size());
    //cout << s1 << endl;
    //cout << s2 << endl;
    }
    //分别处理 s1,s2
    map<char,int> um1;
    map<char,int> um2;
    //s1 按照逗号分割
    vector<string> v1;
    v1 = split(s1,",");
    for(auto e:v1)
    {
    int i;
    char c;
    char c_;
    stringstream ss(e);
    ss >> c >> c_ >> i;
    //cout << "c = " << c << " i = " << i << endl;
    um1[c] = i;
    }
    //s2 按照逗号分割
    vector<string> v2;
    v2 = split(s2,",");
    for(auto e:v2)
    {
    int i;
    char c;
    char c_;
    stringstream ss(e);
    ss >> c >> c_ >> i;
    //cout << "c = " << c << " i = " << i << endl;
    um2[c] = i;
    }
    string res;
    for(auto e:um1)
    {
    res += e.first;
    res += ":";
    res += to_string(e.second-um2[e.first]);
    res += ",";
    }
    for (int j = 0; j < res.size()-1; ++j) {
    cout << res[j];
    }
    cout << endl;
    }
    return 0;
    }
    //a:3,b:5,c:1@
    //a:3,b:5,c:2@a:1,b:2
    wangkai0351
        15
    wangkai0351  
       2019-08-07 21:22:55 +08:00
    zhoudaiyu
        16
    zhoudaiyu  
       2019-08-07 23:17:04 +08:00
    我来发个第一题的,不知道能不能用 Py 实现
    def get_result(given_string):
    return eval((" ".join([items for items in given_string]).replace("1", "True").replace("0", "False").replace("!", "not").replace("&", "and").replace("|", "or")))
    Mountain
        17
    Mountain  
       2019-08-08 00:28:03 +08:00 via iPhone
    公然求助场外观众了?
    summer20100514
        18
    summer20100514  
       2019-08-08 11:17:37 +08:00
    完善拉黑列表
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3930 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 10:24 · PVG 18:24 · LAX 03:24 · JFK 06:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.