User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 455,979 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,786 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 297 | Replies: 1
Reply
Join Date: Nov 2007
Posts: 5
Reputation: marzuki is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
marzuki marzuki is offline Offline
Newbie Poster

Help sorting and class data

  #1  
Nov 28th, 2007
Dear all;

I want to sort and class the random data by using C programming. The below are example of th data:

Diameter Velocity
0.05 1.0
0.05 1.2
0.15 2.2
0.05 1.2
0.25 3.1
0.35 4.3
0.25 3.1
0.35 4.3
0.45 5.7
0.15 2.2
0.15 2.0

I want to get the maximum number of occurence of the velocity for a given size. If you look from above data so the result is:
0.05 = 1.2 (2 times)
0.15 = 2.2 (2 times)
etc...

Could you help me all? how to class the above data ? and also how to read the data in better way because the header is character.

Thanks for your help

Cheers
Marzuki
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,539
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 40
Solved Threads: 972
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: sorting and class data

  #2  
Nov 28th, 2007
use a linked list of structures. Read a value from the file, search the list to see if its already in the list. If found just increment the count. Otherwise if not found then add a new node and initialize the count to 1. Note: for value in the below structure multiply the float read from the file by 100 to get an integer. Don't use floats in the structure because comparisons may be inexact.
struct data
{
     int value;
     int count;
};

>>and also how to read the data in better way because the header is character.
better than what? you didn't post any code.
Last edited by Ancient Dragon : Nov 28th, 2007 at 9:53 am.
<<Freelance Programmer>> << Hobby Site>>
Signature links for sale. PM me for details
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 9:21 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC