Fill Positions of one Array into another Array

This is a discussion on Fill Positions of one Array into another Array within the C++ Programming forums, part of the General Programming Boards category; Okay I have two arrays face *A[21]; face *B[21]; i need to put positions 0-3-6-9-12-15-18 of A into 0 through ...

  1. #1
    Unregistered
    Guest

    Unhappy Fill Positions of one Array into another Array

    Okay I have two arrays

    face *A[21];
    face *B[21];

    i need to put positions 0-3-6-9-12-15-18 of A into 0 through 6 of B
    1-4-7-10-13-14-19 of A into 7 through 13 of B and 2-5-8-11-14-21 of A into 14-20 of B.

    I can't figure out how to do this, any help you can offer will be greatly appreciated.

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Use a temp array to swap between. Swap all of array A into the temp, then copy the section of array B needed into array A. Finally copy the section from array A (stored in the temp array) into array B.

  3. #3
    Registered User Liam Battle's Avatar
    Join Date
    Jan 2002
    Posts
    114
    do your own homework assignment u dink...
    if you ever used arrays before you would know how to do this without a problem.
    LB0: * Life once school is done
    LB1: N <- WakeUp;
    LB2: N <- C++_Code;
    LB3: N >= Tired : N <- Sleep;
    LB4: JMP*-3;

  4. #4
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Originally posted by Liam Battle
    do your own homework assignment u dink...
    if you ever used arrays before you would know how to do this without a problem.

    Come on man, although you might be right, this is not the way to reply to this man, this is not contributing to the thread....plus it's not nice
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,659
    Come on man, although you might be right, this is not the way to reply to this man, this is not contributing to the thread....plus it's not nice
    ...gimme a break! the guy didn't even post any code...



    ITSA
    Socket Library!

  6. #6
    Xei
    Xei is offline
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719

    Calm

    I dont think that any source code was needed for the type of description that he gave. Also, what is the purpose of a message board if people dont co-operate and respect eachother. Its to exchange knowlege and help eachother out. Beginners may struggle with some concepts, just as everyone does as they learn.

  7. #7
    Unregistered
    Guest
    i was just wondering if anyone had anyway to do it in a for loop instead of manually swapping all the values 1 by 1, thanks to most who replied..

  8. #8
    Unregistered
    Guest
    Maybe something like this??

    Code:
    for(int x=0;x<22;x++)
    {
      if(x%3==0)
      {
        B[x/3]=A[x];
        B[x/3+7]=A[x+1];
        B[x/3+14]=A[x+2];
      }
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 1-D array
    By jack999 in forum C++ Programming
    Replies: 24
    Last Post: 05-12-2006, 07:01 PM
  2. 2d array question
    By gmanUK in forum C Programming
    Replies: 2
    Last Post: 04-21-2006, 12:20 PM
  3. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 08:51 AM
  4. Template Array Class
    By hpy_gilmore8 in forum C++ Programming
    Replies: 15
    Last Post: 04-11-2004, 11:15 PM
  5. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21