Given a sequence of 2-digit numbers, use ‘qsort’ to sort the numbers in the following rule:
1. First, sort the numbers by tens digit in increasing order. E.g., 10 is prior to 20.
2. If numbers have the same tens digit, sort them by units digit in decreasing order. E.g., 39 is prior to 38.
Hint:
#include#include #define SIZE 10 #define LENGTH 2 int comp_func(const void *a, const void *b) { /* your code here */ } int main() { int i, N; int num[SIZE][LENGTH]; int *ptr[SIZE]; char str[LENGTH+1]; scanf("%d", &N); for (i=0; i Input
N
Number1
Number2
...
NumberNOutput
Print the sorted numbers line by line. Each line contains one number and ends with a newline character.
Sample Input Download
Sample Output Download
Tags
Discuss