Thread: Putting in order scanned numbers?

  1. #1
    Registered User
    Join Date
    Apr 2006

    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
    There's a bunch of ways to do this, look up "sorting algorithms" on Wikipedia. The easiest is probably to do something like this:

    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
    Oregon, USA
    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
    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
    You type like William Shatner talks.

    Hope is the first step on the road to disappointment.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    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.

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, 09:48 AM
  5. display numbers in order
    By mike in forum C++ Programming
    Replies: 2
    Last Post: 09-24-2001, 09:16 PM