|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Mondsreitersmann
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
|
Howdy fellows,
Can you give me a hand with these insufferable flowcharts for tomorrow's assignment? The problem is this one: Reads in a list of positive numbers (use -1 to represent the end of the list) and prints out the largest and the second largest numbers. (Assume that the list contains at least two numbers.) This is what I have so far. But I cannot find a way to read in the second number, compare it and print it out as the second largest. Any ideas? TIA
__________________
Darum still, füg' ich mich, wie Gott es will. Nun, so will ich wacker streiten, und sollt' ich den Tod erleiden, stirbt ein braver Reitersmann. |
|
|
|
|
|
#2 |
|
Mondsreitersmann
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
|
And the third one is even worse:
Based on 2, find the largest number, the second largest number, and their positions in a list of positive numbers. Assume now that the end_of_list tag is "-1". Given the following data: 10 30 10 20 40 -1, the results are: The largest number is 40 at position 5 The second largest number is 30 at position 2.
|
|
|
|
|
|
#3 |
|
Resident Slacker
Join Date: Dec 2001
Location: Suisun City, California (i know, where the hell is that?!?!?)
Posts: 2,620
|
this is what i came up with for problem 2... it's in excel... i've never worked with flowcharts before, so sorry if it's wrong.
__________________
Friends help you move. REAL friends help you move bodies. - me quite possibly the best book ever written... by me |
|
|
|
|
|
#4 |
|
usual suspect
Join Date: Jun 2002
Location: not here
Posts: 2,051
|
link is not working for me, don't know if you took it down or what
craig
__________________
the universe is against this current wave of success i'm having. -johnny drama, entourage |
|
|
|
|
|
#5 |
|
Mondsreitersmann
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
|
Strange, I haven't moved it and it's working from this side.
|
|
|
|
|
|
#6 |
|
usual suspect
Join Date: Jun 2002
Location: not here
Posts: 2,051
|
just tried it on another computer and it is still not working. oh well, sorry i could not help
craig |
|
|
|
|
|
#7 |
|
Mondsreitersmann
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
|
Here.
|
|
|
|
|
|
#8 |
|
Mondsreitersmann
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
|
Thank you Dok, Hobey and Homer. I got the first one, flowchart and code.
![]() Now, I only have to find a way to keep track of the entered number positions. Any suggestions? |
|
|
|
|
|
#9 | |
|
Member (14 bit)
Premium Member
Join Date: Jan 2002
Location: The Great NorthWest
Posts: 12,594
|
Quote:
Hope the attached is what you are looking for! TwoRails Last edited by TwoRails; 06-14-2008 at 01:18 PM. |
|
|
|
|
|
|
#10 |
|
Resident Slacker
Join Date: Dec 2001
Location: Suisun City, California (i know, where the hell is that?!?!?)
Posts: 2,620
|
on the first problem, don't you want it to output two different numbers? you'd need two variables, then, instead of just the one output.
|
|
|
|
|
|
#12 |
|
Mondsreitersmann
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
|
Now, the second one I'm having problems with.
The values are right, and so is the position for the largest one, but the second largest one always reports 1 as its position. Here's the flowchart And here's the code: Last edited by Nuclear Krusader; 02-04-2004 at 03:22 AM. |
|
|
|
|
|
#13 |
|
Member (8 bit)
Join Date: Jul 2003
Location: "Boondocks", KY
Posts: 184
|
if (number>highest)
{ position1=counter; second_highest=highest; highest=number; } If you already have a value for position1 you need to bump it down to position2, as it was the previous highest and now is only second highest. You notice you already sent the value (second_highest=highest; ), now you need to send the position with it. |
|
|
|
|
|
#14 |
|
Mondsreitersmann
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
|
Thank you all for your help, fellows. I finally got them all sorted out.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|