third largest number 2d arrays

Posted 23 February 2013 - 01:14 PM

my professor has asked us to solve the following problem but im having trouble understanding it

**Write a function that takes in a 2 dimensional array of integers and returns the third largest
number. Let the number of columns of your 2 dimensional array be 5. Call this function from
the main program with 2 different arrays to show that it works.
**

Ive tried to make sense of it and create a code but i am not sure how to call the function in the main function. i tried to create a variable int a[][5], which gave me an error saying that that the first bracket can't be empty. He doesn't specify the number of rows, so should it be 1, by default?

I am trying to understand a function he used in class as example. This was a code to find the second maximum class
which is

I am not quite sure what int rows is supposed to be. isnt a[] supposed to be the number of rows?

If wanted to call this function in the main function, how would i do it?

int main()
{
SecondMax2d(__, ___,___)
// If he gives a question(similar to the one above) where he says it should have 10 columns, without specifying rows, i am not sure what's supposed to go in the first blank, and the last, which is supposed to be int rows.
system("pause");
return 0;
}

Replies To: third largest number 2d arrays

Re: third largest number 2d arrays

Posted 23 February 2013 - 01:49 PM

So basically "I don't know where to start" - This usually means you should go back to your instructor and admit you are this lost. Don't bluff your way through this course thinking that by chapter 10 it will all suddenly snap into place and become clear. It won't. Unlike history class where chapter 1 might be 17th century England and chapter 2 might be World War II, giving you a fresh start - Coding builds upon the lessons of the previous chapter. You have to use lesson 1 material to succeed in lesson 2. Chapter 10 builds upon and uses material from chapter 9. If you let your pride get in the way you will be too lost to recover and have wasted thousands of dollars in tuition.

In short, the teacher isn't doing their job of actually teaching. You can't expect to keep posting after every lecture and have the volunteers here be your free private tutor to make up for a bad teacher. We don't have the resources to do that for each student in each class around the country. And its not right that the teacher get away with doing a bad job and still getting paid.

Re: third largest number 2d arrays

Posted 23 February 2013 - 02:05 PM

tlhIn`toq, on 23 February 2013 - 01:49 PM, said:

So basically "I don't know where to start" - This usually means you should go back to your instructor and admit you are this lost. Don't bluff your way through this course thinking that by chapter 10 it will all suddenly snap into place and become clear. It won't. Unlike history class where chapter 1 might be 17th century England and chapter 2 might be World War II, giving you a fresh start - Coding builds upon the lessons of the previous chapter. You have to use lesson 1 material to succeed in lesson 2. Chapter 10 builds upon and uses material from chapter 9. If you let your pride get in the way you will be too lost to recover and have wasted thousands of dollars in tuition.

In short, the teacher isn't doing their job of actually teaching. You can't expect to keep posting after every lecture and have the volunteers here be your free private tutor to make up for a bad teacher. We don't have the resources to do that for each student in each class around the country. And its not right that the teacher get away with doing a bad job and still getting paid.

If the teacher is that bad you need to go over his head to his boss. You're not the first person with a bad teacher. This is from my FAQ list:

Q: I've been struggling with this for days/weeks and I can't figure it out and my professor is worthless and can't teach. Can someone here explain it to me?A: If you are struggling with how to do this you need to talk to your professor. Let him/her know you are struggling at this early stage in class. Make your professor do the job (s)he gets paid to do by either helping you or finding you a tutor or giving you more exercises from earlier in the book. You are paying for this education. Be an active part in not allowing the teacher to brush you off and let you slip through the cracks. If the other 50 people in class aren't struggling then don't blame the teacher. If the other 50 people are struggling then you all need to go to the professor's superior and tell him/her. If the prof is really incompetent then you don't need to help him keep his cushy 100,000/year job. If the prof isn't incompetent then you need to study harder or consider buying another book on programming. You aren't required to ONLY use the text book provided for the class."How do you resolve your issues" survey.

If the teacher is that bad you need to go over his head to his boss. You're not the first person with a bad teacher. This is from my FAQ list:

Q: I've been struggling with this for days/weeks and I can't figure it out and my professor is worthless and can't teach. Can someone here explain it to me?A: If you are struggling with how to do this you need to talk to your professor. Let him/her know you are struggling at this early stage in class. Make your professor do the job (s)he gets paid to do by either helping you or finding you a tutor or giving you more exercises from earlier in the book. You are paying for this education. Be an active part in not allowing the teacher to brush you off and let you slip through the cracks. If the other 50 people in class aren't struggling then don't blame the teacher. If the other 50 people are struggling then you all need to go to the professor's superior and tell him/her. If the prof is really incompetent then you don't need to help him keep his cushy 100,000/year job. If the prof isn't incompetent then you need to study harder or consider buying another book on programming. You aren't required to ONLY use the text book provided for the class."How do you resolve your issues" survey.

His office hours are "by appointment." i don't want to sound like i am coming up with excuses but he put up this assignment on Thursday, due on Monday the 25th. i didn't have a chance to look at it until yesterday. and now that i am unclear about the question, i have no way to contact him other than by email, which he won't respond to.

If i had another class in between the time that he put up the assignment and the time the assignment was do, i would have definitely gone up to him and asked him to clear it up, believe me.

jimblumberg, on 23 February 2013 - 02:21 PM, said:

Quote

He doesn't specify the number of rows, so should it be 1, by default?

Quote

Call this function from
the main program with 2 different arrays to show that it works.

Looking at these two lines I would say use an array of array[2][5].

Quote

I am not quite sure what int rows is supposed to be. isnt a[] supposed to be the number of rows?

Normally when you pass an array into your function you should also pass the size of this array as well. So rows should be the size of your array.

Re: third largest number 2d arrays

... due on Monday the 25th. i didn't have a chance to look at it until yesterday.

Got it: Not a failing on the part of the teacher, but a failing on the part of the student.

We all live and learn. I'm sure you won't make this mistake again. I'm confident you've learned to examine the assignment more closely as soon as you get it, ask questions and so on even if you don't plan to start it until 48 hours before it is due.

Re: third largest number 2d arrays

... due on Monday the 25th. i didn't have a chance to look at it until yesterday.

Got it: Not a failing on the part of the teacher, but a failing on the part of the student.

We all live and learn. I'm sure you won't make this mistake again. I'm confident you've learned to examine the assignment more closely as soon as you get it, ask questions and so on even if you don't plan to start it until 48 hours before it is due.

It's not failing on the part of the student(other than the fact that i might be stupid too understand this). I have his class on Mondays and Wednesdays. How can i get in touch with someone about something that's not posted until a day later we meet. I don't think it was that big of a crime for me to not see it till the next day. I have other classes, assignments due as well. I didn't not do it out of laziness or indifference.

I am not a computer science major but i've taken programming before, which i did well on. There's failure on both his part and mine(since my brain can't seem to grasp this).

This post has been edited by helloworld1234: 23 February 2013 - 03:33 PM

Re: third largest number 2d arrays

think you need to take your own advice, mr. troll=). you're basically trying to do the same thing i am.

how is asking for help on a program plagiarizing anyway? never asked anyone to write it for me. i actually wrote it myself. besides, the majority of this post consisted of a lecture from a dude about me how i've failed as a student.

This post has been edited by helloworld1234: 25 February 2013 - 08:49 PM