您当前的位置: 首页 > 

TechGuide

暂无认证

  • 4浏览

    0关注

    176博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

网易互娱四道编程题(2020/09/05)

TechGuide 发布时间:2020-09-05 18:36:04 ,浏览量:4

备战秋招面试 微信搜索公众号【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             
关注
打赏
1665329535
查看更多评论
0.0396s