pvjc24/cv1/program.c

38 lines
608 B
C
Raw Permalink Normal View History

2024-02-21 13:04:04 +00:00
#include <stdio.h>
2024-02-17 19:30:32 +00:00
2024-02-21 13:04:04 +00:00
int main() {
2024-02-21 15:40:44 +00:00
int c = 0;
2024-02-21 13:21:57 +00:00
int lines_count = 0;
2024-02-21 15:45:04 +00:00
int was_newline = 0;
2024-02-21 13:04:04 +00:00
while ((c = getchar()) != EOF) {
2024-02-21 15:45:04 +00:00
was_newline = 0;
2024-02-21 15:40:44 +00:00
2024-02-21 15:45:04 +00:00
2024-02-21 13:35:41 +00:00
if (c >= 'a' && c <= 'z') {
2024-02-21 13:04:04 +00:00
c = c - 'a' + 'A';
}
2024-02-21 15:45:04 +00:00
2024-02-21 13:35:41 +00:00
else if (c >= 'A' && c <= 'Z') {
c = c - 'A' + 'a';
}
2024-02-21 15:40:44 +00:00
2024-02-21 15:36:35 +00:00
if (c == '\n') {
2024-02-21 13:35:41 +00:00
lines_count++;
2024-02-21 15:45:04 +00:00
was_newline = 1;
2024-02-21 13:35:41 +00:00
}
2024-02-21 15:40:44 +00:00
2024-02-21 13:28:35 +00:00
putchar(c);
2024-02-21 13:04:04 +00:00
}
2024-02-21 15:40:44 +00:00
2024-02-21 15:45:04 +00:00
if (!was_newline && c != EOF) {
2024-02-21 15:40:44 +00:00
putchar('\n');
2024-02-21 15:38:23 +00:00
}
2024-02-21 15:45:04 +00:00
2024-02-21 14:58:18 +00:00
printf("Lines count: %d\n", lines_count);
2024-02-21 13:04:04 +00:00
return 0;
2024-02-21 15:40:44 +00:00
}