JavaScript is required to use Bungie.net

Service Alert
All Destiny releases will be temporarily offline tomorrow for scheduled maintenance. Please stay tuned to @BungieHelp for updates.

OffTopic

Surf a Flood of random discussion.
10/5/2012 3:55:09 AM
59

Can anyone help with basic C++ stuff?

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
English
#Offtopic #Flood

Posting in language:

 

Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [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; i

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • 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; i

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [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.

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • 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]

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • Download "Code:Blocks" It's got a C++ compiler and a debugger that shows you what needs to be changed.

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [url=http://pastie.org/4913325]Here's how you might do it with STL[/url].

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • 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++.

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [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]

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • Where's Daz when you need him? :O

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • 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

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [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.

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [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).

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • 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.

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [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"<

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [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]

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • 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.

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • 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]

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [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 working

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • Found it!!! you need to use "==" not just "=" to set as new value. Example: largest == number not largest = number

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [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).

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [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 everyone

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • 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. [Edited on 10.04.2012 9:05 PM PDT]

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • 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]

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • ya took a look at his code and its perfect... what part don't you get?

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • [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 important

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • 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

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

You are not allowed to view this content.
;
preload icon
preload icon
preload icon