zoukankan      html  css  js  c++  java
  • 队列

     1 #include <iostream>
     2 #include <queue>
     3 using namespace std;
     4 struct Node
     5 {
     6     int num;
     7     int w;
     8 }node;
     9 int main()
    10 {
    11     queue<Node> q;
    12     int n;
    13     cin >> n;
    14     for(int i = 1; i <= n; i++)
    15     {
    16         node.num = i;
    17         cin >> node.w;
    18         q.push(node);
    19     }
    20     while(q.size() >= 2)
    21     {
    22         cout << q.front().num << " " << q.front().w << endl;
    23         q.pop();
    24         node = q.front();
    25         q.pop();
    26         q.push(node);
    27     }
    28     cout << "size" << q.size() << endl;
    29     cout << q.front().w << endl;
    30     return 0;
    31 }
     1 #include <iostream>
     2 #include <queue>
     3 #include <stdio.h>
     4 using namespace std;
     5 
     6 int main()
     7 {
     8     queue<int> q;
     9     int n;
    10     cin >> n;
    11     int cmp;
    12     for(int i = 0; i < n; i++)
    13     {
    14         cin >> cmp;
    15         q.push(cmp);
    16     }
    17     cout << "size»" << q.size() << endl;
    18     cout << "队首" << q.front() << endl;
    19     cout << "队尾" << q.back() << endl;
    20     while(!q.empty())
    21     {
    22         cout << q.front() << endl;
    23         q.pop();
    24     }
    25     return 0;
    26 }
  • 相关阅读:
    yum 下载安装包以及依赖包
    《将博客搬至CSDN》
    Lucene
    Solr
    LVS原理详解(3种工作模式及8种调度算法)
    正向代理与反向代理
    网关,网卡
    NAT地址转换
    Nginx学习总结
    网络_OSI模型_数据包传输
  • 原文地址:https://www.cnblogs.com/jxust-jiege666/p/6523097.html
Copyright © 2011-2022 走看看