备战秋招面试 微信搜索公众号【TechGuide】关注更多新鲜好文和互联网大厂的笔经面经。 作者@TechGuide 点赞再看,养成习惯,您动动手指对原创作者意义非凡🤝
以下整理于牛客网 1.自动售货机( cpp实现 全A)作者:show_me_offer
链接:https://www.nowcoder.com/discuss/500024?type=3&channel=666&source_id=discuss_center_discuss_hot
来源:牛客网
#include
#include
#include
#include
using namespace std;
struct goods {
int price;
stack others;
};
int main() {
int N, M;
cin >> N >> M;
goods* mp = new goods[N + 1];
for(int i=1;i> mp[i].price;
}
int money = 0;
for (int i = 0; i > operateTimes;
for (int j = 0; j > str1 >> str2;
if (str1 == "left") {
if (str2 == "take") {
cin >> No;
if (mp[No].others.empty()) {
left = mp[No].price;
}
else {
left = mp[No].others.top();
mp[No].others.pop();
}
}
else if (str2 == "return") {
cin >> No;
mp[No].others.push(left);
left = 0;
}
else { // str2 = keep
money += left;
left = 0;
}
}
else {
if (str2 == "take") {
cin >> No;
if (mp[No].others.empty()) {
right = mp[No].price;
}
else {
right = mp[No].others.top();
mp[No].others.pop();
}
}
else if (str2 == "return") {
cin >> No;
mp[No].others.push(right);
right = 0;
}
else { // str2 = keep
money += right;
right = 0;
}
}
}
money = money + left + right;
cout l >> speedl >> speedh;
while (true) {
screen = draw(background, chara, h-1, l-1); //在背景图指定位置画个角色
int diff = different(screen, lastscreen); //和上一张图区别多少字符
lastscreen = screen;
h += speedh;
l += speedl;
sum += diff;
if (h > H && speedh >= 0) break; //这段好像可以写在开始 无所谓了
if (l > W && speedl >= 0) break;
if (h + pH
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?