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>
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() {
char input_char;
char c;
int line_count = 0;
while (1) {
int read_result = scanf("%c", &input_char);
int input = getchar();
if (read_result == EOF) {
break;
if (input == EOF) {
break; // Koniec súboru (EOF)
}
c = (char)input;
c = simulate_caps_lock(c);
if (input_char >= 'a' && input_char <= 'z') {
input_char = input_char - 'a' + 'A';
putchar(c);
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;
}