C++ 페어 큐

Jmnote (토론 | 기여)님의 2024년 1월 13일 (토) 10:38 판 (→‎개요)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

C++ 페어 큐
#include <iostream>
#include <queue>
using namespace std;

int main(){
    queue<pair<int,int>> q;
    q.push({1,2});
    q.push({3,4});
    while(!q.empty()) {
        cout << q.front().first << ", ";
        cout << q.front().second << endl;
        q.pop();
    }
}
#include <iostream>
#include <queue>
using namespace std;

int main(){
    queue<pair<int,int>> q;
    q.push(make_pair(1,2));
    q.push(make_pair(3,4));
    while(!q.empty()) {
        cout << q.front().first << ", ";
        cout << q.front().second << endl;
        q.pop();
    }
}
#include <iostream>
#include <queue>
using namespace std;

int main(){
    queue<pair<int,int>> q;
    q.push(pair<int,int>(1,2));
    q.push(pair<int,int>(3,4));
    while(!q.empty()) {
        cout << q.front().first << ", ";
        cout << q.front().second << endl;
        q.pop();
    }
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}