Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: C++ This time!

  1. GReYVee's Avatar
    Join Date
    06-03-09
    Location
    Colorado
    Posts
    3,346
    Post Thanks / Like
    Stat Links

    C++ This time!
    Gamer IDs

    Steam ID: GReYVee
    #11

    Re: C++ This time!

    Yeah, do not give up if you got time.

    You just gave me another idea of a method that would require less operations, but still recursion.

    Two arrays of references (pointers). One is initalized to all null references. The other is initialized to reference each element in your vector.

    As you generate random indices you do the following.

    1) take reference of element[random] and put it in element[0].
    2) take whatever reference was in element[0], and put it in element[random] in the other array (the blank one).
    3) null out element[random]

    Now as you iterate through, if you encounter an element[random] that is null you know you already chose that element. Recurse to repeat the operation when this happens.

    Once you have moved x% of elements to the blank pointer array, you now fill all the null spots with whatever is left in the original array. Pass that back out.


  2. Registered TeamPlayer Imisnew2's Avatar
    Join Date
    01-19-08
    Posts
    4,588
    Post Thanks / Like
    Blog Entries
    9
    #12

    Re: C++ This time!

    Quote Originally Posted by GReYVee
    Yeah, do not give up if you got time.

    You just gave me another idea of a method that would require less operations, but still recursion.

    Two arrays of references (pointers). One is initalized to all null references. The other is initialized to reference each element in your vector.

    As you generate random indices you do the following.

    1) take reference of element[random] and put it in element[0].
    2) take whatever reference was in element[0], and put it in element[random] in the other array (the blank one).
    3) null out element[random]

    Now as you iterate through, if you encounter an element[random] that is null you know you already chose that element. Recurse to repeat the operation when this happens.

    Once you have moved x% of elements to the blank pointer array, you now fill all the null spots with whatever is left in the original array. Pass that back out.

    VERY good, Thanks! I can do this. I think draco said this, but his was encrypted in that strange intellectual language of his.

  3. Registered TeamPlayer i8pptuakamonstercam's Avatar
    Join Date
    11-26-06
    Location
    Anywhere you want to be.
    Posts
    3,946
    Post Thanks / Like
    Blog Entries
    1
    Stat Links

    C++ This time!
    #13

    Re: C++ This time!

    Quote Originally Posted by HeavyG
    This is a forum for PC hardware and technology... not for you to get help on your homework.

    What are you saying , we need a programming sub forum or something......

  4. GReYVee's Avatar
    Join Date
    06-03-09
    Location
    Colorado
    Posts
    3,346
    Post Thanks / Like
    Stat Links

    C++ This time!
    Gamer IDs

    Steam ID: GReYVee
    #14

    Re: C++ This time!

    Quote Originally Posted by i8pptuakamonstercam
    Quote Originally Posted by HeavyG
    This is a forum for PC hardware and technology... not for you to get help on your homework.

    What are you saying , we need a programming sub forum or something......
    PC Software and Homeworkology?

  5. Administrator Kanati's Avatar
    Join Date
    05-15-08
    Location
    Pekin, Illinois, United States
    Posts
    17,724
    Post Thanks / Like
    Stat Links

    C++ This time! C++ This time! C++ This time! C++ This time! C++ This time! C++ This time!
    #15

    Re: C++ This time!

    Quote Originally Posted by i8pptuakamonstercam
    Quote Originally Posted by HeavyG
    This is a forum for PC hardware and technology... not for you to get help on your homework.

    What are you saying , we need a programming sub forum or something......
    Yeah, if he has a problem with programming, then we need a programming forum. Personally, I think it's a fine place to put programming questions.

    Krakkens and shit. stop tempting them.
    -- Bigdog

  6. Registered TeamPlayer IRON MAN 2142's Avatar
    Join Date
    06-29-08
    Posts
    2,761
    Post Thanks / Like
    Stat Links

    C++ This time!
    Gamer IDs

    Steam ID: _iron_man_
    #16

    Re: C++ This time!

    Quote Originally Posted by Kanati8869
    Quote Originally Posted by i8pptuakamonstercam
    Quote Originally Posted by HeavyG
    This is a forum for PC hardware and technology... not for you to get help on your homework.

    What are you saying , we need a programming sub forum or something......
    Yeah, if he has a problem with programming, then we need a programming forum. Personally, I think it's a fine place to put programming questions.
    Programming seems like Hardware and Technology to me,
    Just sayinn

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Title