diff --git a/cv1/program.c b/cv1/program.c index 4839991..89c0ecd 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,38 +1,25 @@ #include - -char simulate_caps_lock(char c) { - if ('a' <= c && c <= 'z') { - return c - ('a' - 'A'); - } else if ('A' <= c && c <= 'Z') { - return c + ('a' - 'A'); - } else { - return c; - } -} +#include int main() { - char c; int line_count = 0; + char input_char; - while (1) { - int input = getchar(); - - if (input == EOF) { - return -1; - } - - c = (char)input; - c = simulate_caps_lock(c); - - putchar(c); - - if (c == '\n') { + while ((input_char = getchar()) != EOF) { + if (input_char == '\n') { line_count++; } + + if (islower(input_char)) { + input_char = toupper(input_char); + } else if (isupper(input_char)) { + input_char = tolower(input_char); + } + + putchar(input_char); } - printf("%d\n", "Lines count: "line_count); + printf("\nLinesā£count:%d\n", line_count); return 0; } -