diff options
Diffstat (limited to '')
-rw-r--r-- | šola/p2/dn/inverz.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/šola/p2/dn/inverz.c b/šola/p2/dn/inverz.c new file mode 100644 index 0000000..fe8e8b3 --- /dev/null +++ b/šola/p2/dn/inverz.c @@ -0,0 +1,30 @@ +// DN03a +/* + +Prevajanje in poganjanje: + +gcc -o test01 test01.c inverz.c -lm +./test01 + +*/ + +#include <stdio.h> +#include <stdbool.h> + +#include "inverz.h" + +long inverz (long x, long a, long b) { + while (true) { + if (f(a) == x) + return a; + if (f((a+b)/2) < x) { + a = (a+b)/2+1; + continue; + } + b = (a+b)/2; + continue; + } +} + +// Ta datoteka NE SME vsebovati funkcij main in f! +// Funkciji main in f sta definirani v datoteki test01.c. |