I haven't posted in a while, and I don't even know if I'm allowed to ask, but I need some help with debugging my simple programming stuff. If you're willing I can inbox you the code. If not just don't post because flamers aren't cool
-
[quote][b]Posted by:[/b] dazarobbo Multisets (AFAIK) are implemented as hash tables, not arrays. And the change from a for loop to a while loop is pretty trivial. for (int i=0; iMultisets (AFAIK) are implemented as hash tables, not arrays. And the change from a for loop to a while loop is pretty trivial. for (int i=0; i[quote][b]Posted by:[/b] dazarobbo [url=http://pastie.org/4913325]Here's how you might do it with STL[/url].[/quote]That's cheating, he couldn't use arrays, and needed to include a while loop.Awesome, I'm on a programming course to. Where you taking yours? Edit: Posted before I read the thread or what you're trying to solve and found you are also at the exact same point as my programming class... :S [Edited on 10.05.2012 12:42 AM PDT]Download "Code:Blocks" It's got a C++ compiler and a debugger that shows you what needs to be changed.[url=http://pastie.org/4913325]Here's how you might do it with STL[/url].Idk if he already got his answer, but I modified his pastie to work properly and fairly efficiently. [url]http://pastie.org/4912265[/url] As far as syntax goes I am unsure though because I don't code in c++.[quote][b]Posted by:[/b] SENI0R XPL0SIVE hmmm intersting. Learn something new everyday I guess... Dumb ass teacher. Wouldn't hurt if we learned out of a book intsead of from slide shows the guy makes... Yeah[/quote] Whenever you're in doubt, check the API. You will find everything you need to know about C#, from method calls to general information like the list of operators I linked. [Edited on 10.04.2012 9:36 PM PDT]Where's Daz when you need him? :Ohmmm intersting. Learn something new everyday I guess... Dumb ass teacher. Wouldn't hurt if we learned out of a book intsead of from slide shows the guy makes... Yeah[quote][b]Posted by:[/b] SENI0R XPL0SIVE no, C# doesn't recognize "=" when using smbols like <,>,=,+,- or anything else it requires two symbols. Such as ++ -- == >= <= != and so on. It's just how C# works which explains why I was of little help here.[/quote] I have to really disagree with you.[quote][b]Posted by:[/b] SENI0R XPL0SIVE no, C# doesn't recognize "=" when using smbols like <,>,=,+,- or anything else it requires two symbols. Such as ++ -- == >= <= != and so on. It's just how C# works which explains why I was of little help here.[/quote] I don't know who taught you that, but that's not right. Take a look at the [url=http://msdn.microsoft.com/en-us/library/6a71f45d.aspx]list of operators[/url] (click one to see an example of how it works).no, C# doesn't recognize "=" when using smbols like <,>,=,+,- or anything else it requires two symbols. Such as ++ -- == >= <= != and so on. It's just how C# works which explains why I was of little help here.[quote][b]Posted by:[/b] SENI0R XPL0SIVE Found it!!! you need to use "==" not just "=" to set as new value. Example: largest == number not largest = number[/quote] err... no... to use that properly... num = 17 num2 = 7 if (num == num2) cout<<"they are equal"<[quote][b]Posted by:[/b] SENI0R XPL0SIVE Okay so there's one difference at least with C++ and C#. Cause' in C# you use "==" to change the value of something and to compare it. But congrats on getting it to work.[/quote] I'm not trying to be a dick, but that's not good programming practice. It may work, but you should not be using == to assign values. C# follows the same general rules as C++ does. [url=http://msdn.microsoft.com/en-us/library/sbkb459w.aspx]Assignment in C#.[/url] [Edited on 10.04.2012 9:23 PM PDT]Okay so there's one difference at least with C++ and C#. Cause' in C# you use "==" to change the value of something and to compare it. But congrats on getting it to work.You wouldn't assign a value with ==, you would use =. You would use the == operator when you're comparing two values. Take a look at [url=http://www.cplusplus.com/doc/tutorial/operators/]this[/url] for a better explanation. [quote][b]Posted by:[/b] dfisch5 What does this do? I already have the program working[/quote] You're good. SENI0R is just confused. [Edited on 10.04.2012 9:14 PM PDT][quote][b]Posted by:[/b] SENI0R XPL0SIVE Found it!!! you need to use "==" not just "=" to set as new value. Example: largest == number not largest = number[/quote]What does this do? I already have the program workingFound it!!! you need to use "==" not just "=" to set as new value. Example: largest == number not largest = number[quote][b]Posted by:[/b] Razgriz Berkut Whenever there is a bigger number than largest, then you update larger to what largest is. Then you set largest to what number is.[/quote] This. Costly Axis explained it pretty well, I think: [quote]When you set your new largest value, you need to then also update the second largest value to the previously largest number. This is because if the largest value was dwarfed, then so too was the second largest one by the previous largest value.[/quote] All I added was the one line of code to do this (and the braces since there are now two statements).[quote][b]Posted by:[/b] SENI0R XPL0SIVE Well, where's the code for generating the ten numbers you need to run the the rest of the code? Or are you supposed to enter ten numbers manually? Edit: Nevermind found it.[/quote]You manually enter them. And I understand it now. Thanks a lot everyoneWell, where's the code for generating the ten numbers you need to run the the rest of the code? Or are you supposed to enter ten numbers manually? Edit: Nevermind found it. [Edited on 10.04.2012 9:05 PM PDT]Whenever there is a bigger number than largest, then you update larger to what largest is. Then you set largest to what number is. This way, you update the largest value and still keep the 2nd largest value inside larger. [Edited on 10.04.2012 9:05 PM PDT]ya took a look at his code and its perfect... what part don't you get?[quote][b]Posted by:[/b] X Drag0n Fate X np... btw looking back at the code I realized I messed up the algorithm with larger... once the max num is reached it won't read the secound largest[/quote]I used PVR's and it's running perfectly. The only problem now is that I don't really understand it. Which is probably importantnp... btw looking back at the code I realized I messed up the algorithm with larger... once the max num is reached it won't read the secound largest