Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- queue<int>_push(int arr[],int n);
- void _pop(queue<int>s);
- // } Driver Code Ends
- //User function Template for C++
- //User function Template for C++
- queue<int>_push(int arr[],int n)
- {
- queue<int>p;
- //return a queue with all elements of arr inserted in it
- for(int i=0;i<n;i++)
- p.push(arr[i]);
- return p;
- }
- void _pop(queue<int>s)
- {
- //print front and dequeue for each element until it becomes empt
- while(!s.empty()){
- cout<<s.front()<<" ";
- s.pop();}
- }
- // { Driver Code Starts.
- int main() {
- int t;
- cin>>t;
- while(t--)
- {
- int n;
- cin>>n;
- int arr[n];
- for(int i=0;i<n;i++)
- cin>>arr[i];
- queue<int>mys=_push(arr,n);
- _pop(mys);
- cout<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement