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> #include <stdio.h>
#include <ctype.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;
}
}
int main() { int main() {
char c;
int line_count = 0; int line_count = 0;
char input_char;
while (1) { while ((input_char = getchar()) != EOF) {
int input = getchar(); if (input_char == '\n') {
if (input == EOF) {
return -1;
}
c = (char)input;
c = simulate_caps_lock(c);
putchar(c);
if (c == '\n') {
line_count++; 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; return 0;
} }