stdlib.h
This commit is contained in:
parent
c6f1a399af
commit
3a3f6cc424
4 changed files with 262 additions and 11 deletions
27
05/main.c
27
05/main.c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue