From c74c7e09d630b5753d13ed2a9f47ffdeed45bd85 Mon Sep 17 00:00:00 2001 From: VIliam Date: Sat, 24 Feb 2024 20:15:45 +0100 Subject: [PATCH] capslock --- cv1/program.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 88e8acb..e9ce4d2 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,5 +1,4 @@ #include -#include int main() { char input_char; @@ -12,17 +11,26 @@ int main() { break; } - if (islower(input_char)) { - printf("%c", toupper(input_char)); - } else if (isupper(input_char)) { - printf("%c", tolower(input_char)); - } else if (input_char == '\n') { - line_count++; - printf("%c", input_char); - } else if (isprint(input_char)) { - // Print visible characters as they are - printf("%c", input_char); + + if (input_char >= 'a' && input_char <= 'z') { + input_char = input_char - 'a' + 'A'; } + + else if (input_char >= 'A' && input_char <= 'Z') { + input_char = input_char - 'A' + 'a'; + } + + else if (input_char == '\n' || (input_char >= 32 && input_char <= 126)) { + if (input_char == '\n') { + line_count++; + } + } else { + + continue; + } + + + printf("%c", input_char); } printf("%d\n", line_count);