Hi guys,
my question might be quite simple, but I'm stuck and I can't go on. I'm trying to do a C program that determines the maxim value of an array inserted by a user, until here it's not difficult. The thing is that I'd like to print also the position of the maximum, but not only the position at which it occurs the first time, but all the position. That's basically my problem, I don't really know how to save the position. I'm using a "for loop' in order to determine the maximum and also the position, but by doing this also the positions of the previous maxima are saved, so then and the end I get a wrong output.
I hope my problem is clear :P
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
If you post your code, someone can probably provide you with a workable solution within your style.
You only mentioned printing the max and their positions, so in general, you know the old max, the value of input at the current pos, and the pos.
If you need to use the max and its positions later, then you'll need to use a file or perhaps another array holding the positions. The idea would be the same... that is, when you detect a new max, rewind the file or reset the positions array to zero. To end the data set, mark it with -1 or something.
HTH