> Can any one help me to find the largest and smallest
> value in the sequence of intergers ... and print the
> position of the smallest and largest number after each
> number is entered.?
>
> Users will input sequence of nonzero inteters.
>
> Thank You Very Much!
I find this request for help rediculous. It is obviously a school/college assignment and the solution is almost trivial.
If someone posts a solution, is the author going to present it as his own work?
Roger
There's no need to over-react to homework questions. :-)
Certainly don't answer, but there's nothing wrong with
giving a hint--even for problems this trivial.
The naive way would be to store all past data and search
it each time a new number is added to the list.
The smart way is to compare the new number to the previous
min and max values.
I guess the difficulty wasn't really in coming up with the
algorithm (unless the poster is verrry dumb) but in putting
it into Java. That just comes with practice. Read a few
small programs and get to understand them.
It's quite interesting. Do you have to find just first lowest number and it's position, or write all lowest nubers to array with theirs position?
Are that nubers in some kind of tree, or are they as an surface of Voronoi you know what one part of Voronoi diagram?
And by the way at what school do you study, just out of curiosity.
Just wait if they are really sadistic and wanna to prepare you at career of game developer they would give you ray to plane intersection, or ray to 4D object intersection, it would be fun.
> It's quite interesting. Do you have to find just first
> lowest number and it's position, or write all lowest
> nubers to array with theirs position?
I suspect it's just an excruciatingly simple problem.
The sort of exercise a beginner is given:
read a number; print it; read another;
print the smaller, then the greater;
read another;
print the smaller of the new number and previous minimum,
then the greater one;
read another ...
Presumably, terminate when the number is <= 0.
If you want to print the positions of the max and min,
just count the numbers as they're entered, and remember
the positions of the max and min so far.
Quite a nice suggestion for a simple enhancement to the
assignment.
> It's hard to do without using array !!
No, Its significantly easier to do without an array then it is with an
array.
To paraphrase what someone else said a bit earlier.
I have 20 coins of various denominations (values). I give you one coin
at a time. You can only keep one coin. How do you keep the coin with the
largest value.
If you are still having problems with this then get someone to play act
with you. (Doctors and Nurses is always fun)
matfud
> > It's quite interesting. Do you have to find just
> first
> > lowest number and it's position, or write all
> lowest
> > nubers to array with theirs position?
>
> I suspect it's just an excruciatingly simple problem.
>
> The sort of exercise a beginner is given:
> read a number; print it; read another;
> print the smaller, then the greater;
> read another;
> print the smaller of the new number and previous
> minimum,
>then the greater one;
> read another ...
>
> Presumably, terminate when the number is <= 0.
>
> If you want to print the positions of the max and min,
>
> just count the numbers as they're entered, and
> remember
> the positions of the max and min so far.
>
> Quite a nice suggestion for a simple enhancement to
> the
> assignment.
How they can be so cruel. So cripling task for young brain. They should give them task to create Voronoi diagram instead. Just wait next time they would give them task: create sorting algorithm. And in most cases it would be Bubble.
^-^
Raghar
> > It's hard to do without using array !!
>
> No, Its significantly easier to do without an array
> then it is with an
> array.
>
> To paraphrase what someone else said a bit earlier.
>
> I have 20 coins of various denominations (values). I
> give you one coin
> at a time. You can only keep one coin. How do you keep
> the coin with the
> largest value.
>
> If you are still having problems with this then get
> someone to play act
> with you. (Doctors and Nurses is always fun)
>
>
> matfud
>
>
Just don't forget to check for alergy on tape. /and have some backup for that case/ It's allway interesting who goes first. Nurse or Doctor?