all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
17
Task/Sort-an-integer-array/C/sort-an-integer-array.c
Normal file
17
Task/Sort-an-integer-array/C/sort-an-integer-array.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#include <stdlib.h> /* qsort() */
|
||||
#include <stdio.h> /* printf() */
|
||||
|
||||
int intcmp(const void *aa, const void *bb)
|
||||
{
|
||||
const int *a = aa, *b = bb;
|
||||
return (*a < *b) ? -1 : (*a > *b);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int nums[5] = {2,4,3,1,2};
|
||||
qsort(nums, 5, sizeof(int), intcmp);
|
||||
printf("result: %d %d %d %d %d\n",
|
||||
nums[0], nums[1], nums[2], nums[3], nums[4]);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue