This commit is contained in:
pommicket 2022-02-16 15:41:30 -05:00
parent c6f1a399af
commit 3a3f6cc424
4 changed files with 262 additions and 11 deletions

View file

@ -2,9 +2,32 @@
#include <math.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
int main(int argc, char **argv) {
raise(SIGKILL);
int compar(const void *a, const void *b) {
int i = *(int *)a;
int j = *(int *)b;
if (i < j) return -1;
if (i > j) return 1;
return 0;
}
int main(int argc, char **argv) {
ldiv_t l = ldiv(1000000000007, 5937448);
printf("%ld %ld\n",l.quot,l.rem);
int nums[10] = {8,34,1086,3872,-123,5873,3843,1762,INT_MAX,INT_MIN};
int i;
for (i = 0; i < 10; ++i) nums[i] = abs(nums[i]);
qsort(nums, 10, sizeof(int), compar);
for (i = 0; i < 10; ++i) printf("%d ", nums[i]);
printf("\n");
int search = 34;
int *p = bsearch(&search, nums, 10, sizeof(int), compar);
if (p)
printf("Found %d\n",*p);
else
printf("No match\n");
return 0;
}