Submit | All submissions | Best solutions | Back to list |
DATAD - Student Database |
Admin wants to store a student database which includes ID, Name, Mass, Height. You need to write a C code to implement this using structures and linked list.
Linked list is a data structure often used to store similar data in memory. While the elements of an array occupy contiguous memory locations, those of a linked list are not constrained to be stored in adjacent location. The individual elements are stored “somewhere” in memory, but still bound together. The order of the elements is maintained by explicit links between them. Thus, a linked list is a collection of elements called nodes, each of which stores two item of information—an element of the list, and a link, i.e., a pointer or an address that indicates explicitly the location of the node containing the successor of this list element
You have to use a linked-list for storing the students’ information. Each node of the linked-list will be used to hold the information for one student, which includes the ID, name, mass, height. Your program should have insert function to store data,bubble sort function to sort student data in the decreasing order of their Body Mass Index and display function to display data in the sorted order.
The body mass index (BMI), or Quetelet index, is a measure of relative weight based on an individual's mass and height.
it is defined as the individual's body mass divided by the square of their height.
BMI = mass(kg) / (Height(m))2
First line of input contains number of insertions and next lines contains student data (ID name mass height)
Output should display the sorted student data in decreasing order of BMIs (ID name mass height BMI) with two decimal places.
Input :
5
2 Lisa 68 1.65
5 Riya 50 1.5
15 Shyam 70 1.7
35 Raj 48 1.45
12 Divya 65 1.6
Output :
12 Divya 65.00 1.60 25.392 Lisa 68.00 1.65 24.9815 Shyam 70.00 1.70 24.2235 Raj 48.00 1.45 22.835 Riya 50.00 1.50 22.22
Added by: | IT 110 |
Date: | 2014-11-01 |
Time limit: | 15s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C |