How do I write a C++ function void ShiftRight (int A[], int m, int n) to shift all elements in the array A to the right m places. Array A has n elements. For instance, if ARY array has {1,2,3,4,5}, calling ShiftRight(ARY, 2, 5) will change the contents of ARY to {4,5,1,2,3}.

I have no idea on how the do this your help is much appriecated

thank you :)

>I have no idea on how the do
Not a clue? Can't even form a thought? Seriously, are you so incompetent as to be completely unable to come up with anything? It doesn't have to be a complete solution, you know. Programmers tend to work incrementally, solving small problems first to get an idea of what's involved and then working toward a more complete solution for the current problem. For example, you could shift by one element instead of rotate (the name of your function is misleading) and fill the vacated element with 0. That gives you a starting point.

I don't think you're stupid, so I have to conclude that you're lazy and want us to do your homework for you.

no not at all i missed about 2 weeks of classes because of a death in the family, so im behind

I have to conclude that you're lazy and want us to do your homework for you.

I agree. I remember this thread where you tell us that we move very slow with helping you cheat your class. I accidentally gave you positive rep for it... I forgot to click the 'Disapprove' radiobutton.

Store the last element in a temporary variable, start from the end and loop till beginning of the array keep equating i th position to the i-1 th position. After the loop equate the 0th position to the temporarty variable.

This is how I would rotate an array. Repeat the procedure m times to get your answer.

Sorry for the long statement, my pseudo code writing skills are not very good.

np hammer atleast I have an idea on how I can go about starting this, thank you for trying to help me understand instead of being a A**hole like the major of bitter members on this site

instead of being a A**hole like the major of bitter members on this site

And you've just proved my point, thank you very much.

This article has been dead for over six months. Start a new discussion instead.