Update 'cv1/program.c'
This commit is contained in:
parent
d9cc1c347d
commit
5a74eaae4d
@ -3,11 +3,10 @@
|
||||
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') {
|
||||
@ -20,16 +19,18 @@ int main() {
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user