Update 'cv1/program.c'

This commit is contained in:
Tamáš 2024-02-21 15:45:04 +00:00
parent d9cc1c347d
commit 5a74eaae4d

View File

@ -3,33 +3,34 @@
int main() {
int c = 0;
int lines_count = 0;
int last_char_was_newline = 0;
int was_newline = 0;
while ((c = getchar()) != EOF) {
last_char_was_newline = 0;
was_newline = 0;
if (c >= 'a' && c <= 'z') {
c = c - 'a' + 'A';
}
else if (c >= 'A' && c <= 'Z') {
c = c - 'A' + 'a';
}
if (c == '\n') {
lines_count++;
last_char_was_newline = 1;
was_newline = 1;
}
putchar(c);
}
if (!last_char_was_newline) {
if (!was_newline && c != EOF) {
putchar('\n');
}
printf("Lines count: %d\n", lines_count);
return 0;