0

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

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.