Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
prepend
//g++ 7.4.0 //write a function that prepends first n elements of array b ahead of the first m elements of array a. Make sure array a has room for at least m+n elements; //this code is created by Rezaul Hoque on June 16,2021; contact: jewelmrh@yahoo.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <iostream> using namespace std; int size =9; int m=5, n=2; void prepend(int [], int , int [], int); void prepend(int a[], int m, int b[], int n){ int i; for (i=0;i<n; i++) a[i]= b[i];//prepend n elements of b at the start of a, starting from index i ; for(i=0;i<size;i++) cout<<" "<<a[i]; } int main () { int size =9; int m=5, n=2; int a[size]={0,0,1,2,3,4,5,0,0};//size of array a must have ample room so that we could put the elements of b at the start of it; for this reason , n elements at the start and rest of the array a are filled with 0 int b[n]={6,7}; prepend(a,5,b,2); return 0; }
run
|
edit
|
history
|
help
0
Vectors as Inputs to Map
2021(M2)Simulare:S3:1
Microsoft - MaxEmployeeAttendence (R repititions - 1st step towards DP solution)
Menu Combination Sum
Test1
iviewb
Operator Overload
C++ Solar eclipse program(Shoushi integrated) 1568 - 1644 also check Lunar eclipse for Xing Yunlu
cppPyGuessTheNum2
A • Potato Sacks