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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.