stack,queue

#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <map>
#include <stack>
#include <cmath>
#include <iomanip>
#include <set>
#include <cmath>
#include <cctype>

#include<climits>
//INT_MAX 32 bit int
//LLONG_MAX 64 bit int
//LONG_MAX 64 bit int

using namespace std;

#define SPO(n) fixed << setprecision(n)
#define endl '\n'
#define ifor(i, l, r) for (long long(i) = (l); (i) <= (r); ++(i))
#define rfor(i, r, l) for (long long(i) = (r); (i) >= (l); --(i))

typedef long long ll;
typedef pair<int, int> P;
typedef unsigned long long ull;

const int IINF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1.0e-9;
const long long MOD = 1e9 + 7;
const long long MAX = 1e5 + 5;

struct sun {
    int a;
    int b;
    bool operator<(const struct sun &d) const {
        return this->b < d.b;
    }
};

sun node[3] = {{12, 56},
               {89, 3},
               {5, 637}};
bool cmp(int &a ,int &b)
{
    return a>b;
}
int main() {
    string s;

    stack<int> a;
    a.push(4);
    cout << a.top() << endl;
    a.pop();
    a.emplace(56);
    cout << a.top() << endl;
    a.pop();
    if (a.empty())
        cout << "Afds" << endl;

    queue<int> b;
    b.push(560);
    b.push(45);
    while (!b.empty()) {
        cout << b.front() << " " << b.back() << endl;
        b.pop();
    }

    priority_queue<sun, vector<sun> > c;
    ifor(i, 1, 4) {
        c.push(sun{1, i});
    }
    while (!c.empty()) {
        cout << (c.top()).b << " ";
        c.pop();
    }
    cout<<endl;
    priority_queue<int,vector<int>> d;
    d.push(56);
    d.push(0);
    d.push(4);
    d.push(100);
    while(!d.empty())
    {
        cout<<d.top()<<" ";
        d.pop();
    }
    cout<<endl;


    int acc[5]={0,5,89,1,2};
    sort(acc,acc+5,cmp);
    for(auto a:acc)
    {
        cout<<a<<" ";
    }
    return 0;
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
03-10 14:27
已编辑
点赞 评论 收藏
分享
头像
02-26 13:58
门头沟学院 Java
北城_阿亮:把八股背一背,包装一下实习经历项目经历,要是有心思考证就考一考,然后把别人的项目爬到自己github上,包装到简历里,什么三个月?一个月!
点赞 评论 收藏
分享
01-23 14:54
同济大学 Java
热爱敲代码的程序媛:给你提几点【专业技能】这个模块里面可优化的地方:1.【具备JVM调优经验】可以去b站上搜一下JVM调优的视频,估计一两个小时凭你的学习能力就能掌握JVM调优的实践方面的技能。2.【MySql优化】MySql这一栏,你去b站或者找个博客看看MySql优化,学一下,如果你本身比较熟悉MySql语句的话,那基本半天时间凭你的学习能力MySql语句优化方面的技能你也能掌握个差不多。以上1,2两点主要是因为我看你专业技能大部分都说的是偏理论,没有写应用。再就是最后,你结合你的项目,想一想你的项目中哪些sql语句是可以用MySql优化的,到时候你面试的时候也好结合着说一下。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务