奇安信8.16笔试

总共两题,第一题发奖金,题干错了,我已反馈,大家快去反馈!!!坑了我一个小时,A了0%
int CalulateMethodCount(int num_money) {
    // write code here
    vector<int> dp(num_money + 1, 0);
    dp[0] = 1; dp[1] = 1;
    for (int i = 2; i <= num_money; i++) {
        for (int j = 0; j < i; j++) {
            dp[i] += dp[j];
        }
    }
    return dp[num_money];
}
第二题输入一行字符串,里面包含undo和redo,分别代表撤销和恢复,比如:
输入  Hello undo redo World.
输出  Hello World.
用了两个栈来回倒腾,不知道为啥只过了80%
int main()
{
    string tmp;
	stack<string> a;
	stack<string> b;
	while (cin >> tmp)
	{
		if (tmp == "undo") {
			if (a.empty()) continue;
			b.push(a.top());
			a.pop();
		} else if (tmp == "redo") {
			if (b.empty()) continue;
			a.push(b.top());
			b.pop();
		} else {
			a.push(tmp);
		}
		if (cin.get() == '\n') break;
	}
	vector<string> t(a.size());
	int idx = a.size() - 1;
	while (!a.empty())
	{
		t[idx--] = a.top();
		a.pop();
	}
	for (string s : t) {
		cout << s << ' ';
	}
}





#笔试题目#
全部评论
同样的思路。。。。也是ac0...请问楼主是怎么反馈的呀
点赞 回复
分享
发布于 2020-08-16 23:34
所以第一题是啥意思,就是这么做的么
点赞 回复
分享
发布于 2020-08-31 21:07
小红书
校招火热招聘中
官网直投
没有选择题吗?
点赞 回复
分享
发布于 2020-09-01 10:37

相关推荐

点赞 5 评论
分享
牛客网
牛客企业服务