This commit is contained in:
Weber 2024-02-21 19:15:04 +00:00
parent d79643777b
commit e0d6b4ed32

View File

@ -1,22 +1,21 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h>
int main() { int main() {
char ch; int ch;
int line_count = 0; int line_count = 0;
while ((ch = getchar()) != EOF) { while ((ch = getchar()) != EOF) {
if (ch == '\n') { if (ch == '\n') {
putchar('\n'); putchar('\n');
line_count++; line_count++;
} else { } else {
if (isprint(ch)) { if (!((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) && !(ch >= 32 && ch <= 126)) {
putchar((ch >= 'a' && ch <= 'z') ? (ch - 32) : ((ch >= 'A' && ch <= 'Z') ? (ch + 32) : ch)); continue; // Skip control characters and non-printable characters
}
else {
putchar(ch);
} }
putchar((ch >= 'a' && ch <= 'z') ? (ch - 32) : (ch + 32));
} }
} }
printf("\nLines count: %d\n", line_count); printf("\nLines count: %d\n", line_count);
return 0; return 0;
} }