This commit is contained in:
Džubara 2024-02-24 20:23:56 +01:00
parent c74c7e09d6
commit a277448c46

View File

@ -1,39 +1,37 @@
#include <stdio.h> #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;
}
}
int main() { int main() {
char input_char; char c;
int line_count = 0; int line_count = 0;
while (1) { while (1) {
int read_result = scanf("%c", &input_char); int input = getchar();
if (read_result == EOF) { if (input == EOF) {
break; break; // Koniec súboru (EOF)
} }
c = (char)input;
c = simulate_caps_lock(c);
if (input_char >= 'a' && input_char <= 'z') { putchar(c);
input_char = input_char - 'a' + 'A';
if (c == '\n') {
line_count++;
} }
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); printf("\nPocet nacitanych riadkov: %d\n", line_count);
return 0; return 0;
} }