Recommended Posts

Hello,

I am trying to write a method that returns the index of a two dimensional array, I want to pass the array to the method and have it return the indices of a specific value. I am unclear if it is possible to return multple values (int's in my case) or if there is a better way. I know I can simply put the search algorithm in main, but Im trying to stick to a modular design (might as well get into the habit now). Any suggestions are well appreciated, thank you.

Link to post
Share on other sites
There's no simple way to return multiple values. The easy solution would be to return an int[2] containing the indices.

Ill look into that, what I initially wanted was to have the method ONLY search the array, pass the indices back to main to be passed to another method to change the value of the location. What I decided to do (at least for now) is pass the array to the method have it find and change the value and return the array, I dont know if this is an efficient way to do it but it works.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...