Thread: putting an array of 10 integers in order

  1. #1
    They Call me Mister Sako
    Join Date
    Jul 2004

    putting an array of 10 integers in order

    i cant think of a good way to do this, if i was to have an integer array of 10 different random integers, then i want to put them in order in a dfferent array how would i go about doing this?
    AIM: MisterSako | MSN: | E-mail:
    The goal of computer science is to be lazy

  2. #2
    Wen Resu
    Join Date
    May 2003
    Look into sorting methods, this is a common topic, do a board search

  3. #3
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    If you want to learn how to code a sort, then definitely search for appropriate techniques. If this just needs to get done, use std::sort in <algorithm>.

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    The classic simple method is a bubble-sort. Note that a bubble-sort does not sort the values into a new array. It uses a single temporary variable to allow you to swap two values at a time in the original array.

    Whatever method you use, you will have to loop-through the array multiple times.

    If you write your own algorithm (such as simply looking for the lowest value, then the next-lowest value) make sure you can handle duplicate values in the array.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading a file
    By nhubred in forum C++ Programming
    Replies: 3
    Last Post: 05-21-2009, 11:34 AM
  2. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  3. Divide and Conquer: array in the reverse order
    By Steamer in forum C Programming
    Replies: 11
    Last Post: 03-08-2004, 07:31 PM
  4. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 12:09 PM
  5. reverse the order of an array
    By dustyd in forum C++ Programming
    Replies: 4
    Last Post: 01-23-2003, 11:14 AM