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

2019-08-07 19:26:08 +08:00
 angelcstt

RT

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

感谢

3315 次点击
所在节点    程序员
18 条回复
angelcstt
2019-08-07 19:35:30 +08:00
大佬在哪里 求助大佬啊 有偿都可以
angelcstt
2019-08-07 19:38:30 +08:00
msaionyc
2019-08-07 19:38:44 +08:00
你题目给完整了吗
angelcstt
2019-08-07 19:39:22 +08:00
@msaionyc 大佬等我拍完整
wateryessence
2019-08-07 19:40:08 +08:00
牛客网问去
angelcstt
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
2019-08-07 19:50:32 +08:00
第一题没拍全吧,估计考查的是中缀后缀表达式。
angelcstt
2019-08-07 19:51:56 +08:00
@lxy42 第一题下面补充了大佬
brainfxxk
2019-08-07 20:10:22 +08:00
第一个表达式求值 第二个字符串处理...
lxy42
2019-08-07 20:46:36 +08:00
第二题用一个长度为 26 的数组表示字符集,数组元素值等于对应字符的个数。两个数组相减就是结果。
Leigg
2019-08-07 21:02:54 +08:00
能不能换个图床,这个很渣
angelcstt
2019-08-07 21:04:46 +08:00
@Leigg 提交了,谢谢啦
angelcstt
2019-08-07 21:04:53 +08:00
@lxy42 谢谢啦
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
2019-08-07 21:22:55 +08:00
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
2019-08-08 00:28:03 +08:00
公然求助场外观众了?
summer20100514
2019-08-08 11:17:37 +08:00
完善拉黑列表

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/589925

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX