pvjc24/cv1/program.c

39 lines
610 B
C
Raw Normal View History

2024-02-23 13:00:03 +00:00
#include <stdio.h>
2024-02-23 12:58:04 +00:00
2024-02-24 19:23:56 +00:00
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;
}
}
2024-02-24 19:02:50 +00:00
int main() {
2024-02-24 19:23:56 +00:00
char c;
2024-02-24 19:02:50 +00:00
int line_count = 0;
while (1) {
2024-02-24 19:23:56 +00:00
int input = getchar();
2024-02-24 19:02:50 +00:00
2024-02-24 19:23:56 +00:00
if (input == EOF) {
break; // Koniec súboru (EOF)
2024-02-24 19:02:50 +00:00
}
2024-02-24 19:23:56 +00:00
c = (char)input;
c = simulate_caps_lock(c);
2024-02-24 19:15:45 +00:00
2024-02-24 19:23:56 +00:00
putchar(c);
if (c == '\n') {
line_count++;
}
2024-02-23 12:58:04 +00:00
}
2024-02-24 19:02:50 +00:00
2024-02-24 19:25:11 +00:00
printf("%d\n", line_count);
2024-02-24 19:02:50 +00:00
return 0;
2024-02-23 12:58:04 +00:00
}
2024-02-24 19:02:50 +00:00