文章

12

粉丝

10

获赞

0

访问

1.7k

头像
合并果子 题解:栈+队列也可以
P1544 中南大学机试题
发布于2024年3月19日 10:53
阅读数 125

#include<iostream>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int Fru[10000+1],n;
stack<int>A;
queue<int>B;
int Sum = 0;

int Min_AB()//找出当前最小并且弹出
{
    int a,b;
    if(A.size()+B.size() == 1)
    {
        int t;
        if(!A.empty())
        {
            t = A.top();A.pop();
            return t;
        }
        t = B.front();B.pop();
        return t;
    }

    if(A.empty())
    {
        a = B.front();B.pop();
        return a;
    }
   &nbs...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发