Saturday, 15 May 2010

c++ - How to use array address to reverse an array? -


I understand the array address, but the code I received in a book has made me nose. I understand the recurring function, but it does not get one. Here's the code:

  int main () {int int array = 5; Int one [array] = {32, 27, 64, 18, 95}; Cout & lt; & Lt; "There are values ​​in the reverse array:" & lt; & Lt; Endl; Some functions (A, array size); Cout & lt; & Lt; Endl; Cin.get (); Return 0; } Some functions with zero (int b [], int size) {if (size> gt; 0) {someFunction (& amp; b [1], shape - 1); Cout & lt; & Lt; B [0] & lt; & Lt; ""; }}  

I have received this code in a drill. My question is how is this array changing? I would be happy if someone would explain a bit more.

Here are some pseudo codes that show how someFunction is recusive calls Some functions ({64, 18, 95}, 4) some functions ({64, 18, 9 5) some functions ({32, 27, 64, 18, 95}, 5) some functions Some functions ({}, 0) Some functions ({}, 0) Some functions ({18, 95}, 2) Some functions ({95}, 1) Some functions ({}, 0)

Nothing is doing because there is nothing left in the array. Now some functions first element [0] as ARMS it comes out of recurrence, starting with an array containing only one item {95}:

95

Then your output will be:

  "values ​​in the reverse array are:" 95 18 64 27 32  

No comments:

Post a Comment