From d22428779d0d0b88d19a70e43dbafdec30afb3dd Mon Sep 17 00:00:00 2001 From: Miloslav Macko Date: Thu, 22 Feb 2024 14:42:41 +0100 Subject: [PATCH] 22,2 --- cv1/program.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 466e1f0..05af661 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,26 +1,26 @@ #include -#include int main() { - int lines_count = 0; int c; + int lines = 0; while ((c = getchar()) != EOF) { - if (islower(c)) { - putchar(toupper(c)); - } else if (isupper(c)) { - putchar(tolower(c)); - } else { + if (c >= 'a' && c <= 'z') { + c -= 32; + } else if (c >= 'A' && c <= 'Z') { + c += 32; + } + + if (c == '\n') { + lines++; + } + + if (c >= 32 && c <= 126) { putchar(c); - if (c == '\n') { - lines_count++; - } } } - printf("Počet načítaných riadkov: %d\n", lines_count); + printf("\nPočet načítaných riadkov: %d\n", lines); return 0; - - -} \ No newline at end of file +}