summaryrefslogblamecommitdiffstats
path: root/šola/p2/dn/inverz.c
blob: fe8e8b3b92814801672c2e776d6a231ec521ea55 (plain) (tree)





























                                                         
// 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.