Putting in order scanned numbers?

This is a discussion on Putting in order scanned numbers? within the C Programming forums, part of the General Programming Boards category; If I scan 10 numbers, how I put them in increasing order?...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    24

    Putting in order scanned numbers?

    If I scan 10 numbers, how I put them in increasing order?

  2. #2
    Registered User
    Join Date
    Jun 2006
    Posts
    5
    There's a bunch of ways to do this, look up "sorting algorithms" on Wikipedia. The easiest is probably to do something like this:

    Code:
    int numbers[10]; //Containing your numbers
    
    int min = numbers[0];
    
    for(int i = 0; i < 10; i++) {
      for(int j = i; j < 10; j++)
        MIN(numbers[j], min);
      if(min != numbers[i])
        //Swap the two with a temp variable
    }

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,171
    We're not here to do your homework for you. Give it a shot and we will give help when you get stuck and have a specific question.

    Of course you would have known this if you had read the Announcement at the top of the thread list.
    If you understand what you're doing, you're not learning anything.

  4. #4
    Registered User
    Join Date
    Mar 2005
    Posts
    37
    Y don't you give it a shot.. and come back with the problems.. you face.. rather than expecting us to do the homework.. ??

    If your intestion is to learn.. then.. you need to change your ways.. !!

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You type like William Shatner talks.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,755
    Kirk: Spock - what is it?
    Spock: It's code captain, but not as we know it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Arranging numbers in ascending order
    By Aero in forum C++ Programming
    Replies: 7
    Last Post: 12-22-2001, 07:52 AM
  2. unique randomly generated numbers
    By grobe59 in forum C++ Programming
    Replies: 1
    Last Post: 11-07-2001, 08:26 PM
  3. arranging randomly generated numbers in ascending order
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 11-05-2001, 07:14 PM
  4. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 10:48 AM
  5. display numbers in order
    By mike in forum C++ Programming
    Replies: 2
    Last Post: 09-24-2001, 10:16 PM

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