This commit is contained in:
Džubara 2024-02-25 21:20:22 +01:00
parent 69f62e88c0
commit aa2877397f

View File

@ -1,38 +1,25 @@
#include <stdio.h>
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 <ctype.h>
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);
}
printf("%d\n", "Lines count: "line_count);
putchar(input_char);
}
printf("\nLines␣count:%d\n", line_count);
return 0;
}