summaryrefslogtreecommitdiff
path: root/05/main.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-02-16 15:41:30 -0500
committerpommicket <pommicket@gmail.com>2022-02-16 15:41:30 -0500
commit3a3f6cc424de23c5b4705644b6377ffee2491b31 (patch)
tree41ae3d6414befe8ed1bddc4699b2fc197c35bfee /05/main.c
parentc6f1a399afc367271ada1d58f09fc00e3d298ce8 (diff)
stdlib.h
Diffstat (limited to '05/main.c')
-rw-r--r--05/main.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/05/main.c b/05/main.c
index 59d6ccd..d16347e 100644
--- a/05/main.c
+++ b/05/main.c
@@ -2,9 +2,32 @@
#include <math.h>
#include <stdio.h>
#include <signal.h>
+#include <stdlib.h>
+
+
+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) {
- raise(SIGKILL);
+ 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;
}