From 4a50937dab4e744190ddd600b06c82e647af4619 Mon Sep 17 00:00:00 2001 From: Yaroslav Orlianskyi Date: Wed, 2 Mar 2022 14:14:37 +0100 Subject: [PATCH] SAD --- du1/program.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/du1/program.c b/du1/program.c index 60a051f..185ba7c 100644 --- a/du1/program.c +++ b/du1/program.c @@ -2,32 +2,17 @@ int main(){ int c = 0; - int a = 0; - int counter = 0; - char small[] = "abcdefghijklmnopqrstuvwxyz"; - char big[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - char d; - while(c = 1){ + char a; + while(1){ c = getchar(); - d = c; - int a = 0; - if(d == '\n'){ - counter++; + if(c == EOF) break; - } - while(a > 26){ - if(d == small[a]){ - d = big[a]; - break; - }else if(d == big[a]){ - d = small[a]; - break; - } - a++; - } - c = d; - putchar (c); + if (c >= 'a' && c <= 'z') + c = c - 'a' + 'A'; + else if(c >= 'A' && c <= 'Z') + c = c - 'A' + 'a'; + a = c; + putchar(a); } - printf("\nPočet riadkov: %d\n",counter); return 0; }