CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Bubble sort in struct

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Orcino



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

Bubble sort in struct
PostPosted: Sun Nov 26, 2006 3:00 pm     Reply with quote

Hi, how to use a bubble sort in struct below for var distancia ?

thanks

Orcino


Code:


struct SGPSCoord
{
    int32 buffer_latitude;
    int32 buffer_longetude;
    int16 distancia;
    int8 status;
};

struct SGPSCoord GPSCOORD[100];


 
jma_1



Joined: 08 Feb 2005
Posts: 147
Location: Wisconsin

View user's profile Send private message

PostPosted: Sun Nov 26, 2006 4:49 pm     Reply with quote

Greetings,

Try using the search utility built into the forum. Searching for 'bubble' I came up with a posting by another forum member which provided sample code for a bubble sort.

http://www.ccsinfo.com/forum/viewtopic.php?t=25168&highlight=bubble

All sorts (bubble, selection, etc) are well known algorithms and are in any programming text book as well as online (bubble sort in google returns to many hits to count).

Did you look for bubble sort anywhere? Is the question how to access members of a structure? Again, there are numerous examples of this in the CCS files themselves (CAN library, etc) as well as in previous posts.

JMA
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 26, 2006 5:08 pm     Reply with quote

I think this is homework. I'm not going to do your homework for you,
but I think your question is about how to swap two structures. The
swap is the main part of a bubble sort. Here's a macro to swap two
structures. You do the rest of it.
Code:

struct SGPSCoord temp_struct;

#define swap(x,y)  temp_struct = x; x = y; y = temp_struct;
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group