Go Back   PCMech Forums > General & Off Topic > General Discussion

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 02-03-2004, 06:34 PM   #1
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
Pissed Flowcharts from hell

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.
Nuclear Krusader is offline   Reply With Quote
Old 02-03-2004, 07:28 PM   #2
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
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.


Nuclear Krusader is offline   Reply With Quote
Old 02-03-2004, 07:38 PM   #3
Resident Slacker
 
homer15's Avatar
 
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.
Attached Files
File Type: zip problem2.zip (2.8 KB, 50 views)
__________________
Friends help you move. REAL friends help you move bodies. - me
quite possibly the best book ever written... by me
homer15 is offline   Reply With Quote
Old 02-03-2004, 08:27 PM   #4
usual suspect
 
hobey19's Avatar
 
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
hobey19 is offline   Reply With Quote
Old 02-03-2004, 08:45 PM   #5
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
Strange, I haven't moved it and it's working from this side.
Nuclear Krusader is offline   Reply With Quote
Old 02-03-2004, 09:08 PM   #6
usual suspect
 
hobey19's Avatar
 
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
hobey19 is offline   Reply With Quote
Old 02-03-2004, 09:11 PM   #7
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
Here.
Attached Files
File Type: zip problem2a.zip (5.8 KB, 41 views)
Nuclear Krusader is offline   Reply With Quote
Old 02-03-2004, 10:59 PM   #8
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
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?
Nuclear Krusader is offline   Reply With Quote
Old 02-03-2004, 11:25 PM   #9
Member (14 bit)
Premium Member
 
TwoRails's Avatar
 
Join Date: Jan 2002
Location: The Great NorthWest
Posts: 12,594
Quote:
Originally posted by Nuclear Krusader
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.


Well, I didn't see the "based on" part until I finish my little diddie. Attached is some Pseudo code for you. You should be able to easily transform it to a flowchart.

Hope the attached is what you are looking for!

TwoRails

Last edited by TwoRails; 06-14-2008 at 01:18 PM.
TwoRails is offline   Reply With Quote
Old 02-04-2004, 01:00 AM   #10
Resident Slacker
 
homer15's Avatar
 
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.
homer15 is offline   Reply With Quote
Old 02-04-2004, 01:05 AM   #11
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
OK.

Here's the final version of the first problem.

And its C++ code:
Attached Files
File Type: txt highest.txt (706 Bytes, 33 views)
Nuclear Krusader is offline   Reply With Quote
Old 02-04-2004, 01:07 AM   #12
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
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:
Attached Files
File Type: txt prob3a.txt (997 Bytes, 30 views)

Last edited by Nuclear Krusader; 02-04-2004 at 03:22 AM.
Nuclear Krusader is offline   Reply With Quote
Old 02-04-2004, 09:19 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.
DarkHorse is offline   Reply With Quote
Old 02-04-2004, 09:05 PM   #14
Mondsreitersmann
 
Nuclear Krusader's Avatar
 
Join Date: Jul 1999
Location: Skingrad
Posts: 8,735
Thank you all for your help, fellows. I finally got them all sorted out.
Nuclear Krusader is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:00 PM.
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0