+ 4
How can I use this code of Merge Sort for all types of variables?
My code is for doubles And I want to make it work for even strings Please help and up vote https://code.sololearn.com/cchDE4W23786/?ref=app
2 Respuestas
+ 1
You can simply make the function a template. However, you will need to come up with a solution for the lines 23 and 24, as filling array elements with a fixed double value is not generic, though it might even work for strings (with a warning, at least).
Here is how it could look like:
https://code.sololearn.com/c0aI1qZ7EoU7/?ref=app
You can change the input type on line 6 for testing purposes as I commented in the code.
+ 3
Thanks