luyencode / comments

Server lưu trữ bình luận trên Luyện Code
https://luyencode.net
6 stars 3 forks source link

https://oj.luyencode.net/problem/QUEUE #889

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Truy vấn với hàng đợi - Luyện Code Online

https://oj.luyencode.net/problem/QUEUE

ntanthedev commented 1 year ago

Đây là code mình đã AC, bạn có thể tham khảo: ``

include<bits/stdc++.h>

define ll long long

const int N = 1e6+9; using namespace std; ll T, x, n; dequeq; void sub1(){ cin>>n; q.push_back(n); } void sub2(){ if(!q.empty()) q.pop_front(); } void sub3(){ if(q.empty()) cout<<"Empty!"<<'\n'; else cout<<q.front()<<'\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); cin>>T; while(T--){ cin>>x; if(x == 1) sub1(); if(x == 2) sub2(); if(x == 3) sub3(); } } ``