rafid_shad

queue assingment

Nov 30th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int t,n,m;
  6.     cout<<"Enter how many test case you want"<<endl;
  7.     cin>>t;
  8.     for(int i=1;i<=t;i++)
  9.     {
  10.         cout<<"Test case : "<<i<<endl;
  11.         cout<<"How many data you want to enter in queue"<<endl;
  12.         cin>>n;
  13.         int a[n];
  14.         for(int j=0;j<n;j++)
  15.         {
  16.             cin>>a[j];
  17.         }
  18.         cout<<"M = ";
  19.         cin>>m;
  20.         cout<<endl;
  21.         if(m<n)
  22.         {
  23.             for(int j=0;j<m;j++)
  24.             {
  25.                 cout<<a[j]<<" ";
  26.             }
  27.             cout<<endl<<"In Queue : ";
  28.             for(int j=m;j<n;j++)
  29.             {
  30.                 cout<<a[j]<<" ";
  31.             }
  32.             cout<<endl;
  33.         }
  34.         if(m>=n)
  35.         {
  36.             for(int j=0;j<n;j++)
  37.             {
  38.                 cout<<a[j]<<" ";
  39.             }
  40.              cout<<endl<<"In Queue : Empty"<<endl;
  41.         }
  42.     }
  43.     return 0;
  44. }
Add Comment
Please, Sign In to add comment