summaryrefslogtreecommitdiffstats
path: root/šola
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2024-03-16 14:50:42 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2024-03-16 14:50:42 +0100
commitad96c7d3ba422133c7367b8454e42cc0796a497d (patch)
treeb4857c88c212fcdd298fde10a2aca24c495bac6d /šola
parentp2.DN02 (diff)
downloadr-ad96c7d3ba422133c7367b8454e42cc0796a497d.tar
r-ad96c7d3ba422133c7367b8454e42cc0796a497d.tar.gz
r-ad96c7d3ba422133c7367b8454e42cc0796a497d.tar.bz2
r-ad96c7d3ba422133c7367b8454e42cc0796a497d.tar.lz
r-ad96c7d3ba422133c7367b8454e42cc0796a497d.tar.xz
r-ad96c7d3ba422133c7367b8454e42cc0796a497d.tar.zst
r-ad96c7d3ba422133c7367b8454e42cc0796a497d.zip
Diffstat (limited to 'šola')
-rw-r--r--šola/p2/dn/BERIME.txt3
-rw-r--r--šola/p2/dn/DN01a_63230317.c16
-rw-r--r--šola/p2/dn/DN01a_63230317.kasnejša_sprememba_po_oddaji.c36
-rw-r--r--šola/p2/dn/DN01b_63230317.c16
-rw-r--r--šola/p2/dn/inverz.c30
-rw-r--r--šola/p2/dn/tranzitivnost.c39
6 files changed, 87 insertions, 53 deletions
diff --git a/šola/p2/dn/BERIME.txt b/šola/p2/dn/BERIME.txt
deleted file mode 100644
index b4dd127..0000000
--- a/šola/p2/dn/BERIME.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Medtem ko so rešitve DN v mapi ../p1/dn ustrezne (pravilne), rešitve tu niso, ker jih pred oddajo nisem preverjal s skritimi testnimi primeri, ampak sem jih samo oddal.
-
-Recimo za prvo nalogo sem dobil nič točk, zato pazite, ko te rešitve uporabljate za učenje -- morda so napačne!
diff --git a/šola/p2/dn/DN01a_63230317.c b/šola/p2/dn/DN01a_63230317.c
index da8e64b..f55755a 100644
--- a/šola/p2/dn/DN01a_63230317.c
+++ b/šola/p2/dn/DN01a_63230317.c
@@ -18,14 +18,16 @@ void printInt (int a) {
a = -a;
putchar('-');
}
- int števke[29];
- int len = 0;
- while (a > 0) {
- števke[len++] = a%10;
- a /= 10;
+ int l = 1;
+ int c = a/10;
+ while (c > 0) {
+ l *= 10;
+ c /= 10;
+ }
+ while (l) {
+ putchar('0'+(a/l)%10);
+ l /= 10;
}
- for (int i = len-1; i >= 0; i--)
- putchar('0'+števke[i]);
}
int main (void) {
printInt(nextInt()+nextInt());
diff --git a/šola/p2/dn/DN01a_63230317.kasnejša_sprememba_po_oddaji.c b/šola/p2/dn/DN01a_63230317.kasnejša_sprememba_po_oddaji.c
deleted file mode 100644
index f55755a..0000000
--- a/šola/p2/dn/DN01a_63230317.kasnejša_sprememba_po_oddaji.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <stdio.h>
-int nextInt () {
- int r = 0;
- int minus = 0;
- for (int števka = '0'; števka == '-' || (števka <= '9' && števka >= '0'); števka = getchar()) {
- if (števka == '-') {
- if (r != 0)
- break;
- minus = !minus;
- continue;
- }
- r = r*10+števka-'0';
- }
- return minus ? -r : r;
-}
-void printInt (int a) {
- if (a < 0) {
- a = -a;
- putchar('-');
- }
- int l = 1;
- int c = a/10;
- while (c > 0) {
- l *= 10;
- c /= 10;
- }
- while (l) {
- putchar('0'+(a/l)%10);
- l /= 10;
- }
-}
-int main (void) {
- printInt(nextInt()+nextInt());
- putchar('\n');
- return 0;
-}
diff --git a/šola/p2/dn/DN01b_63230317.c b/šola/p2/dn/DN01b_63230317.c
index 6952c95..88ef9a9 100644
--- a/šola/p2/dn/DN01b_63230317.c
+++ b/šola/p2/dn/DN01b_63230317.c
@@ -4,14 +4,16 @@ void printInt (int a) {
a = -a;
putchar('-');
}
- int števke[29];
- int len = 0;
- while (a > 0) {
- števke[len++] = a%10;
- a /= 10;
+ int l = 1;
+ int c = a/10;
+ while (c > 0) {
+ l *= 10;
+ c /= 10;
+ }
+ while (l) {
+ putchar('0'+(a/l)%10);
+ l /= 10;
}
- for (int i = len-1; i >= 0; i--)
- putchar('0'+števke[i]);
}
int main (void) {
while (getchar() == '0');
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.
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.