diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-03-03 23:51:25 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-03-03 23:51:25 +0100 |
commit | 63c6de829ec31ca53acc20e7681c7e034dd0d61a (patch) | |
tree | ab7879cf4893cb4083b03ebad22cc865f617ab62 /šola/p2 | |
parent | guanxi (diff) | |
download | r-63c6de829ec31ca53acc20e7681c7e034dd0d61a.tar r-63c6de829ec31ca53acc20e7681c7e034dd0d61a.tar.gz r-63c6de829ec31ca53acc20e7681c7e034dd0d61a.tar.bz2 r-63c6de829ec31ca53acc20e7681c7e034dd0d61a.tar.lz r-63c6de829ec31ca53acc20e7681c7e034dd0d61a.tar.xz r-63c6de829ec31ca53acc20e7681c7e034dd0d61a.tar.zst r-63c6de829ec31ca53acc20e7681c7e034dd0d61a.zip |
Diffstat (limited to 'šola/p2')
-rw-r--r-- | šola/p2/dn/DN01a_63230317.c | 34 | ||||
-rw-r--r-- | šola/p2/dn/DN01b_63230317.c | 24 |
2 files changed, 58 insertions, 0 deletions
diff --git a/šola/p2/dn/DN01a_63230317.c b/šola/p2/dn/DN01a_63230317.c new file mode 100644 index 0000000..da8e64b --- /dev/null +++ b/šola/p2/dn/DN01a_63230317.c @@ -0,0 +1,34 @@ +#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 števke[29]; + int len = 0; + while (a > 0) { + števke[len++] = a%10; + a /= 10; + } + for (int i = len-1; i >= 0; i--) + putchar('0'+števke[i]); +} +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 new file mode 100644 index 0000000..cebcc83 --- /dev/null +++ b/šola/p2/dn/DN01b_63230317.c @@ -0,0 +1,24 @@ +#include <stdio.h> +void printInt (int a) { + if (a < 0) { + a = -a; + putchar('-'); + } + int števke[29]; + int len = 0; + while (a > 0) { + števke[len++] = a%10; + a /= 10; + } + for (int i = len-1; i >= 0; i--) + putchar('0'+števke[i]); +} +int main (void) { + while (getchar() == '0'); + int po_prvi_enici = 0; + while ((getchar() & ~1) == '0') + po_prvi_enici++; + printInt(++po_prvi_enici); + putchar('\n'); + return 0; +} |