Question: Question 4: Excel (Bonus 10%) (using C programming) You are asked to sort the spreadsheet based on some sorting criteria. The figures below can help

Question 4: Excel (Bonus 10%) (using C programming)

You are asked to sort the spreadsheet based on some sorting criteria. The figures below can help you understand the basic idea of this question. You are provided a spreadsheet together with the header and data type of each column (either string, integer or float). Then, the order (either ascending or descending) is also specified. We use lexicographical order for strings, while we use numeric order for both integer and float. You need to output the sorted spreadsheet. All values should look exactly the same as the input. You can safely assume that (i) there are no duplicate rows, (ii) the priority of the sort will start from column 1 to the last column (e.g. if the first three columns are exactly the same, we will continue to column 4. If column 4 is still the same, we will continue to look at column 5). (iii) All strings do not contain space with its length at most 100.

Your program should read the input from the file, and output the answer to another file. The first argument is the input file name, while the second argument is the output file name. Name your program as lab2-q4.c.

4

Input file: First line, n m, two integers describe the size of spreadsheet, n row, m columns. Second line, m distinct words, each word describes the data type of a column (either string, integer or float). Third line, m distinct words, each word specifies the order of a column (either ascending or descending). Fourth line, m distinct words, the header of each column. Following n lines, the data of the spreadsheet, each entry is separated by a space.

Output file: First line, m distinct words, the header of each column. Following n lines, the sorted data of the spreadsheet, each entry is separated by a space.

Sample Input:

55 integer float string string float ascending descending ascending descending ascending ABCDE 123 12.8 C110 Yes 0.05 154 12.75 C118 No 0.05

165 12.8 C117 84 12.73 C117 123 12.6 C118

Sample Output:

ABCDE 84 12.73 C117 123 12.8 C110 123 12.6 C118 154 12.75 C118 No 0.05 165 12.8 C117 Yes 0.01

Yes 0.01 Yes 0.05 No 0.01

Yes 0.05 Yes 0.05 No 0.01

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!