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 }
  • 相关阅读:
    Python格式符号
    Python基础知识
    HDFS 数据流程
    HDFS IO流操作
    HDFS API操作
    Hadoop 客户端环境准备
    Hadop 环境搭建 windows10+hadoop2.7.7
    Hadoop HDFS shell
    Hadoop HDFS 基础
    centos 更改清华源
  • 原文地址:https://www.cnblogs.com/jxust-jiege666/p/6523097.html
Copyright © 2011-2022 走看看