Answer to Question #267701 in C++ for asif

Question #267701

We need to implement some shuffling of two listsin c++.

1. Provide a function which takes two lists and shuffles them. This shuffling should go in an alternating way. First node from first list, second node front second list, third node front first list, 4th node front second list……. So on. If length of list 1 is greater than size of list 2, start again from the first node and follow the same procedure.


1
Expert's answer
2021-11-17T17:34:17-0500
#include<iostream>
using namespace std;
void shuffle(int arr1[], int arr2[], int m, int n){
	int k = m +n;
	int arr3[k];
	int x = 0;
	int a = 0;
	for(int i=0; i<k; i++){
		arr3[i] = arr1[x];
		arr3[i+1] = arr2[a];
		x++;
		a++;
 	}
 	
 	for(int i=0; i<k; i++){
 		cout<<arr3[i]<<" ";
	 }
}
int main(){
	
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS