So I got a homework assignment where I have twenty hardcoded ints, each a random number. Some can be the same. Using passByValue, I need print the three highest numbers.
Now I already have this planned out. The numbers will be declared in main, each number will be sent to a new function, probably called sort. There I'd have three ints that will take whichever number is higher (the number being passed through, or the number already in each spot) and then assign the bigger of the two to that int, progressing to the other two in that function.
I have two problems, though. Problem one is in main. The homework instructions explicitly state that I cannot use arrays. So all I'm able to imagine is just simply twenty different ints, each with a different value. The problem here is, though, I can't really just sort them all at the same time if I'm utilizing passByValue. Or perhaps I can, but it wouldn't look pretty, and pretty is what the teacher is looking for.
So problem one, is how do I effectively pass each of the ints to the sort function one-by-one?
Problem two: I don't want the print function to print out the three largest numbers until it is done sorting. The only way I can imagine this working, is somehow holding the values from being sent to the print function until the line of ints in main has run out. But I'm not sure if that is possible...
Obviously I'm not looking for the entire code. All I really am looking for is just a direction to follow. Whether I can utilize some form of recursion both in the main and sort function or structs (though I don't know if my teacher would appreciate me using those, since they're similar to arrays) or something else.