This is a partial judge problem OwO
You are given N integers. You need to sort them in decreasing order.
#include<stdio.h> #include<stdlib.h> #include "function.h" #define maxn 100005 int arr[maxn]; int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&arr[i]); qsort(arr+1, n, sizeof(int),cmp); for(int i=1;i<=n;i++) { if(i != 1) printf(" "); printf("%d",arr[i]); } printf("\n"); return 0; }
int cmp(const void*, const void*);
You need to implement the cmp function which is the fourth parameter of the qsort function in main function.
The first line contains one integer N (1 ≤ N ≤ 105) – the number of integers you are given.
The second line contains N integers a1, a2, ..., aN (1 ≤ ai ≤ 105).
Ouput the given N integers in decreasing order.