From 444fe4a6ec74a160f21063b3d655d3a5e0d75d17 Mon Sep 17 00:00:00 2001 From: randomuser Date: Fri, 16 Jul 2021 16:28:09 -0500 Subject: [PATCH] make scream smaller --- c/scream.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/c/scream.c b/c/scream.c index eacf2a9..981f687 100644 --- a/c/scream.c +++ b/c/scream.c @@ -5,30 +5,18 @@ * good night and good riddance */ char newchar(char c, int i) { - switch(i) { - case 0: - if(isupper(c)) return c + 32; - if(c == 33) return -2; - else return c; - case 1: - if(islower(c)) return c - 32; - if(c == 33) return -2; - else return c; - default: return -1; - } -} -int advi(int i) { - switch(i) { - case 0: return 1; - case 1: return 0; - default: return -1; - } + if(i % 2) { + if(islower(c)) return c - 32; + } else if(isupper(c)) return c + 32; + if(c == 33) return -2; + return c; } int main(void) { char c; - int i = 0; + int i; + i = 0; while((c = getchar()) != EOF) { putchar(newchar(c, i)); - i = advi(i); + i++; } }