summaryrefslogtreecommitdiffstats
path: root/šola/p2/dn/inverz.c
blob: fe8e8b3b92814801672c2e776d6a231ec521ea55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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.