putting an array of 10 integers in order

This is a discussion on putting an array of 10 integers in order within the C++ Programming forums, part of the General Programming Boards category; i cant think of a good way to do this, if i was to have an integer array of 10 ...

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

    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: sakotheinsane@hotmail.com | E-mail: klinerr1@nc.rr.com
    The goal of computer science is to be lazy

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

  3. #3
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    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
    Posts
    1,398
    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, 05:55 PM
  3. Divide and Conquer: array in the reverse order
    By Steamer in forum C Programming
    Replies: 11
    Last Post: 03-08-2004, 06:31 PM
  4. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 11:09 AM
  5. reverse the order of an array
    By dustyd in forum C++ Programming
    Replies: 4
    Last Post: 01-23-2003, 10:14 AM

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