Thread: moving arrays

  1. #1
    Unregistered
    Guest

    moving arrays

    im confused i have to take an array of numbers and trade them....for example take a[0] and trade it with a[5],then trade a[1] with a[4] and a[2] with a[3].... i just need some help cause i really dont understand. any help will be appreciated thanx

  2. #2
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    int temp, a[10];

    // fill array

    temp = a[0];
    a[0] = a[5];
    a[5] = temp;

    That could get pretty long if you did the entire array like that... so you would want to substute a logical integer variable in for the array delimiter.

    a[integer1]
    a[integer2]

    and substitute numbers as applicable while looping through array to swap values....

    It all depends on what you are doing...
    Blue

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  2. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  3. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  4. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM
  5. moving n-dimentional arrays in c++
    By kknla in forum C++ Programming
    Replies: 0
    Last Post: 02-06-2002, 05:15 PM