diff options
Diffstat (limited to 'šola/p2/dn/DN01b_63230317.c')
-rw-r--r-- | šola/p2/dn/DN01b_63230317.c | 16 |
1 files changed, 9 insertions, 7 deletions
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'); |