![]() |
|
#1
|
|||
|
|||
sortingI don't know why this program isn't compiling right. Maybe I'm not getting something right? Some help would be greatly appreciated.
CPP / C++ / C Code:
Last edited by admin II : 26-Jan-2007 at 08:46.
Reason: please surround your c++ code with [cpp] ... [/cpp]
|
|||
|
#2
|
|||
|
|||
Re: sortingQuote:
CPP / C++ / C Code:
|
|
#3
|
|||
|
|||
Re: sortingHey, ok for starters all the definitions for the variables should be at the top. Secondly, your directions are confusing, one says you should average numbers, the other says you should find the largest number in the array. from what i understand, this is how i would write your main function...
(I would have them enter the numbers before it gets to the function) CPP / C++ / C Code:
and now for the function, ( which from my understanding should find the largest number in the array and give it's index number.) CPP / C++ / C Code:
that should work, if it doesnt, notify me. -Matt Last edited by admin II : 26-Jan-2007 at 08:47.
Reason: please surround your c++ code with [cpp] ... [/cpp]
|
|
#4
|
|||
|
|||
Re: sortingI'm still getting errors. Here is the code:
CPP / C++ / C Code:
The errors I am getting are line 25, which is: Code:
What's the problem? Last edited by admin II : 26-Jan-2007 at 08:48.
Reason: please surround your c++ code with [cpp] ... [/cpp]
|
|
#5
|
|||
|
|||
Re: sortinggive me some time to figure it our, i rid of the errors, but it needs some fixing.
|
|
#6
|
|||
|
|||
Re: sortingOk. Thank you. In the mean time, I am working on another program and getting errors with it as well. I think my problem is with the directions, they're so vague. Anyway, here is the code if you can figure this out too, or someone else please?
CPP / C++ / C Code:
Last edited by admin II : 26-Jan-2007 at 08:49.
Reason: please surround your c++ code with [cpp] ... [/cpp]
|
|
#7
|
|||
|
|||
Re: sortingFirst, why do you use an enumeration when all you define is a single variable which is supposed to be a constant (The maximum number of elements)? I suggest that you place a line after the include of this sort:
#define MAX 10 or in case you dont want this "macro" through all your program, make a constant in the classe's private area. (const int MAX 10) Next thing, you forgot a semi-colon after head = +1; and I also suggest you initialise it to 0 instead of 1. Obviously by changing this the logic of put() and get() will be slightly altered. Your next problem is that there is no variable top, which you use as an index of the array. Then in function get() you do operations after the return, however as you have returned, they will not happen! And finally cout << queue1; is certainly giving you an error as this operation is not defined for classes. So this is my sugestion as the full program corrected, and asking some questions to the user (if he wishes to add a new element or retrieve one) CPP / C++ / C Code:
I believe this is it and I hope this helps... |
|
#8
|
|||
|
|||
Re: sortingThank you, that seems to work just fine. I have another problem, this is the last one I swear! I'm totally lost with this program. Any help would be appreciated!
CPP / C++ / C Code:
Last edited by admin II : 26-Jan-2007 at 08:49.
Reason: please surround your c++ code with [cpp] ... [/cpp]
|
|
#9
|
|||
|
|||
Re: sortingQuote:
Quote:
|
|
#10
|
|||
|
|||
Re: sortingHere is what I have now:
CPP / C++ / C Code:
Last edited by admin II : 26-Jan-2007 at 08:50.
Reason: please surround your c++ code with [cpp] ... [/cpp]
|
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help with sorting d-dimensional points | acosgaya | C++ Forum | 2 | 25-Jun-2006 08:35 |
| question on sorting items is not clear...plz help me | gvsivannarayana | C Programming Language | 0 | 28-Mar-2006 00:26 |
| Problem with sorting algorithm | MM4o | C++ Forum | 3 | 24-Feb-2006 09:40 |
| sorting string w/strcmp | doc_watson2007 | C Programming Language | 4 | 20-Nov-2004 09:17 |
| sorting question | fj8283888 | C Programming Language | 1 | 13-Apr-2004 20:42 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The