CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Arrays

  1. #1
    Join Date
    Jul 2009
    Posts
    1

    Arrays

    I am not very familiar with arrays but I need to use one for a program I'm making so my question is, is there any way to randomly assign the data in one array to the data in another. I'm trying to randomly assign specific values so I can't use a random number generator.

  2. #2
    Join Date
    May 2007
    Location
    Scotland
    Posts
    1,164

    Re: Arrays

    Is this homework?

    Are you coding in C or C++?

  3. #3
    Join Date
    Apr 2007
    Location
    Mars NASA Station
    Posts
    1,436

    Re: Arrays

    OK. The idea like this.

    Initialize first value with zero, second value with one and increment the value and assign to next index. After finish assign, random shuffle it.

    Then using std::copy algorithm to another array.
    Thanks for your help.

  4. #4
    Join Date
    Oct 2005
    Location
    England
    Posts
    803

    Re: Arrays

    You can't use the random number generator to generate specific values yes, but you can use it to generate random array indexs to copy your specific values to.
    Last edited by Rich2189; July 24th, 2009 at 02:13 PM.
    Rich

    Visual Studio 2010 Professional | Windows 7 (x64)
    Ubuntu

  5. #5
    Join Date
    Aug 2007
    Posts
    858

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured