_ChArMz
2011-09-02 15:22:21
#1: Finding the largest of a set of numbers.
You have a set of positive numbers with one negative number(-1) at the end. Once you get to the -1 you have exhausted the set of numbers.
#2: Explain how you would locate both the largest and second largest numbers. (Expand on #1)
Is this as simple as looping though them all or am I missing something…this is not a coding assignment, just like a word problem
High? High(Integer) and High(Integer) - 1?
_ChArMz
2011-09-02 15:37:34
From: pur3b100d
High? High(Integer) and High(Integer) - 1?
again :)…this is a word problem I was given, im not trying to do this in scar
and that would not work even in scar anyway, you would have to sort first
Ah im not sure what your trying to do, are you just trying to think of a method find two numbers?
TRiLeZ
2011-09-02 16:05:30
While keeping a record of the highest and second highest numbers, iterate though the set and compare the each iteration with the highest and second highest numbers. If the current iteration is higher than the highest, set it as the highest and set the old highest as second highest. If the current iteration is higher than the second highest, but lower than the highest, set it as the second highest. If the current iteration is -1, then you are done.
Would that work?
_ChArMz
2011-09-02 16:25:04
From: TRiLeZ
While keeping a record of the highest and second highest numbers, iterate though the set and compare the each iteration with the highest and second highest numbers. If the current iteration is higher than the highest, set it as the highest and set the old highest as second highest. If the current iteration is higher than the second highest, but lower than the highest, set it as the second highest. If the current iteration is -1, then you are done.
Would that work?
yeah, but I feel that i am wrong becuz that is soo simple
From: _ChArMz
yeah, but I feel that i am wrong becuz that is soo simple
Why would you expect a complicated answer, the thing you are trying to explain is trivial. :)
Wizzup?
2011-09-05 16:18:58
From: _ChArMz
#1: Finding the largest of a set of numbers.
You have a set of positive numbers with one negative number(-1) at the end. Once you get to the -1 you have exhausted the set of numbers.
#2: Explain how you would locate both the largest and second largest numbers. (Expand on #1)
Is this as simple as looping though them all or am I missing something…this is not a coding assignment, just like a word problem
It is as simple as looping them. Loop over it; at all times keep the two largest numbers. When you reach -1, you have the largest and second largest number.