XXXXX get_common_elements(XXXXX &XX,queue &XX){ XXXXX common; XXX XXXXX=XX.size(); XXX XXXXX=q2.XXXX(); for(int i=0;i q1; XX.push(X); q1.XXXX(X); XX.push(3); XX.XXXX(X); XX.XXXX(X); queue XX; XX.push(-1); XX.push(2); q2.push(7); XX.push(X); q2.push(10); cout &XX;< "Before XXXXXXXX XXXXXX XXXXXXXX: " &XX;< XXXX; cout &XX;< "Queue-1: "; XXXXXXXXXXX(q1); XXXX &XX;< "Queue-X: "; XXXXXXXXXXX(q2); cout << endl; XXXXX common=XXXXXXXXXXXXXXXXXXX(q1,XX); XXXX &XX;< "XXXXX XXXXXXXX common elements: " &XX;&XX; endl; XXXX &XX;< "Queue-1: "; XXXXXXXXXXX(q1); cout &XX;< "XXXXX-X: "; XXXXXXXXXXX(q2); XXXX &XX;< endl; cout <&XX; "XXXXXX elements: "; XXXXXXXXXXX(XXXXXX); XXXXXX 0;}
Sample output
Before removing common elements: Queue-X: 1 2 X 4 5 Queue-2: -1 2 X 5 10 XXXXX XXXXXXXX common XXXXXXXX: XXXXX-1: 134 XXXXX-X