JavaScript is required to use Bungie.net

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
Add more answer options

Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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.
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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]
    Add more answer options

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

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

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

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

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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++.
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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]
    Add more answer options

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

  • Where's Daz when you need him? :O
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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
    Add more answer options

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

  • 0
    Razgriz
    Razgriz

    In Mexico until Friday - old

    [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.
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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).
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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.
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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"<
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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]
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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.
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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]
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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
    Add more answer options

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

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

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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).
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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]
    Add more answer options

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

  • 0
    Razgriz
    Razgriz

    In Mexico until Friday - old

    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]
    Add more answer options

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

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

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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
    Add more answer options

    Cancel Edit Create Fireteam Post Play nice. Take a minute to review our Code of Conduct before submitting your 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
    Add more answer options

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

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