On the Wednesday morning in week 15, TA remembers that HT gives students a homework, which is related to quick sorting with struct.
Now, TA wants to examine that whether you did the homework.
We will give you a list of objects, each has three attributes: a int number, a string, and a float number.
And you should sort them according to int number first, and then string, and then float number.
(All in the descending order. For example: int number 3 is behind 4 in output list)
(For example: string annie is behind string apple in output list)
HINT: If you don't understand the meaning of the problem after reading above, please see the sample IO and think clearly :)
You should implement funcion.c below and submit it. (Due to Partial judge)
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "function.h"int compare_function(const void* a, const void* b){// set appropriate type// first sorted by value// if equal then soreted by str// if still equal then sorted by x}
You should see .c and .h file below to know how the function and the whole program works.
Input will contain four lines.
First line contains N, indicating the number of objects you should read.
The following three lines contain each object's three attributes: a int number, a string, and a float number.
( 0 < N < 100, 0 < len(string) < 30)
Output contain N lines. (And you should printf "\n" in the end)
You should show the sorted objects in each line in descending order.