Skip to content

Instantly share code, notes, and snippets.

@you74674
Created December 27, 2017 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save you74674/03a55ac9f17fe1cb9d7a7bd6ca9dea98 to your computer and use it in GitHub Desktop.
Save you74674/03a55ac9f17fe1cb9d7a7bd6ca9dea98 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include"compare.h"
int bigger(int a, int b)
{
return a>b;
}
int smaller(int a, int b)
{
return a<b;
}
int main()
{
int C;
scanf("%d", &C);
for(int c=0; c<C; c++)
{
int n;
char command[2];
scanf("%s %d", command, &n);
int k[n];
for(int i=0; i<n; i++)
scanf("%d", &(k[i]));
int (*compare)(int, int)=(command[0]=='>')?bigger:smaller;
sort(k, n, compare);
for(int i=0; i<n; i++)
printf("%d ", k[i]);
printf("\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment