rafid_shad

queue lab

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