Queue L question and input output specification are in the p
Queue L
 question and input output specification are in the picture
in great need for answer in c programing language
 
 which can output as the sample output when there is sample input as the picture shows according to the question
 T T
and so many time someone give me the ans that need more info but didnt tell me what info he need.. it makes me really down
 ..sorry i really dont have other infoT_T
thx for ur kindly help_
 and if that works ill give u a like:)
Solution
#include <stdio.h>
struct stack
 {
    int stk[5];
    int top;
 };
typedef struct stack STACK;
 STACK C; //stack station C
int A[100]; //train A
 int B[100]; //train B
 void main ()
 {
    int sizeA, sizeB, i, j, flag, temp;
    C.top = -1;
    flag = 0;
   printf(\"Enter size for train A:\\t\");
    scanf(\"%d\", &sizeA);
    printf(\"Enter size for train B:\\t\");
    scanf(\"%d\", &sizeB);
    //make sure train A and B aren\'t more than 100
    while(sizeA >100 || sizeB>100){
        printf(\"Length within 100\");
        printf(\"Enter size for train A:\\t\");
        scanf(\"%d\", &sizeA);
        printf(\"Enter size for train B:\\t\");
        scanf(\"%d\", &sizeB);
    }
    //if size not same automatically no
    if(sizeA!=sizeB){
        printf(\"No\");
    }
    else{
        printf(\"Enter sequence for train A:\ \");
        for(i=0; i<sizeA; i++){
            scanf (\"%d\", &temp);
            A[i] = temp;
        }
        printf(\"Enter sequence for train B:\ \");
        for(i=0; i<sizeB; i++){
            scanf (\"%d\", &temp);
            B[i] = temp;
        }
        j = 0;
        //push every carriage in A into stack C
        for(i=0; i<sizeA; i++){
            C.top = C.top+1;
            //if station C overflows then not possible
            if(C.top>=5){
                flag = 1;
                break;
            }
            C.stk[C.top]=A[i];
            //check if top of C matches with sequence in B and pop till match happens.
            while(C.stk[C.top]==B[j] && C.top>-1){
                C.top = C.top-1;
                j++;
            }
        }
        //printf(\"%d\", C.top);
        //if carriage empty and flag is 0 means all carriage has been popped in sequence
        if(C.top== -1 && flag == 0){
            printf(\"Yes\ \");
        }
        else{
            printf(\"No\ \");
        }
    }
 }


