Created
September 28, 2013 01:50
-
-
Save aguegu/6737549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstdlib> | |
int compare (const void * a, const void * b) { | |
return ( *(int*)b - *(int*)a ); | |
} | |
void max(int *buff, int length, int * p1, int *p2) { | |
qsort(buff, length, sizeof(int), compare); | |
*p1 = buff[0]; | |
*p2 = buff[1]; | |
} | |
int main(int argc, char **argv) { | |
printf ("hello, world."); | |
int s[4] = {0, 1, 2, 3}; | |
int max1, max2; | |
max(s, 4, &max1, &max2); | |
printf("%d %d\n", max1, max2); | |
exit(0); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment