0
I want a function in cpp that will return reversed array..
If I take array A from main function and pass to function .. In that function i want to create new array that will store reversed elements. And a function will return that reversed array.. I want to print reverse array in main function..
4 ответов
+ 5
cpp already has a function like this.
use #include<algorithm> and call std:: reverse(iterrable.begin(), iterrable.end());
+ 4
You can define it with only 10 lines of code.
+ 3
There are several tutorials on creating functions such as reverse, strip, chop, tolowercase, etc. All of them use a for loop and manipulate each character using conditionals.
Google them out. They are pretty handy
0
Loop up how to return an array from a function first....
https://www.tutorialspoint.com/cplusplus/cpp_return_arrays_from_functions.htm
then.... in that function...use reverse_copy from the algorithm header file.
http://www.cplusplus.com/reference/algorithm/reverse_copy/