summaryrefslogtreecommitdiffstats
path: root/šola/p2/dn/tranzitivnost.c
diff options
context:
space:
mode:
Diffstat (limited to 'šola/p2/dn/tranzitivnost.c')
-rw-r--r--šola/p2/dn/tranzitivnost.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/šola/p2/dn/tranzitivnost.c b/šola/p2/dn/tranzitivnost.c
new file mode 100644
index 0000000..3456631
--- /dev/null
+++ b/šola/p2/dn/tranzitivnost.c
@@ -0,0 +1,39 @@
+// DN03b
+/*
+
+Prevajanje in poganjanje:
+
+gcc -o test01 test01.c tranzitivnost.c -lm
+./test01
+
+*/
+
+#include <stdio.h>
+#include <stdbool.h>
+#include "tranzitivnost.h"
+
+int tranzitivnost (int a, int b) {
+ bool enica = true;
+ bool antitranz = true;
+ bool tranz = true;
+ for (int i = a; i <= b; i++)
+ for (int j = a; j <= b; j++)
+ for (int k = a; k <= b; k++)
+ if (f(i,j) && f(j,k)) {
+ enica = false;
+ if (!f(i,k))
+ tranz = false;
+ if (f(i,k))
+ antitranz = false;
+ }
+ if (enica)
+ return 1;
+ if (tranz)
+ return 2;
+ if (antitranz)
+ return 3;
+ return 4;
+}
+
+// Ta datoteka NE SME vsebovati funkcij main in f!
+// Funkciji main in f sta definirani v datoteki test01.c.