Thread: manually sorting cards

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #13
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by brewbuck View Post
    Direct placement sort. Draw 100 squares on the ground, labeled 1-100. For each card, place it on the matching square. Now pick them up in order. (This is a special case of rank sort)

    Even more efficient, don't sort the cards at all, but merely imagine that they are sorted.
    Hmm

    Code:
    int* DPSort(int *Data)
    {
    	int Table[100];
    	int SortedData[100];
    	unsigned int i = 0;
    	for(; i < 100; i++)
    	{
    		Table[i] = i+1;
    	}
    	
    	for(i = 0; i < 100; i++)
    	{
    		for(unsigned int j = 0; j < 100; j++)
    		{
    			if(Data[i] == Table[j])
    			{
    				SortedData[j] = Data[i];
    				break;
    			}
    		}
    	}
    	
    	return SortedData;
    }
    Something tells me this will be very inefficient?

    Edit: Ready to flame the first one to comment my poor code!
    Last edited by Neo1; 05-13-2008 at 12:33 PM.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with linked list sorting function
    By Jaggid1x in forum C Programming
    Replies: 6
    Last Post: 06-02-2009, 02:14 AM
  2. Help it won't compile!!!!!
    By esbo in forum C Programming
    Replies: 58
    Last Post: 01-04-2009, 03:22 PM
  3. Help!For poker game simulation
    By tx1988 in forum C++ Programming
    Replies: 24
    Last Post: 05-25-2007, 09:59 PM
  4. Cribbage Game
    By PJYelton in forum Game Programming
    Replies: 14
    Last Post: 04-07-2003, 10:00 AM
  5. playing ... cards??
    By GiraffeMan in forum C Programming
    Replies: 16
    Last Post: 02-06-2002, 03:51 PM