![](https://img2018.cnblogs.com/blog/1608836/201904/1608836-20190422232907260-424713073.png)
# 7.12.1
#include <stdio.h>
int main(void)
{
char ch;
int space_count = 0;
int linebreak_count = 0;
int other_count = 0;
while ((ch = getchar()) != '#')
{
if (ch == ' ')
space_count++;
else if (ch == '
')
linebreak_count++;
else
other_count++;
}
printf("space is %d, line break is %d, other char is %d
",
space_count, linebreak_count, other_count);
printf("Done!
");
return 0;
}
# 7.12.1 other version
#include <stdio.h>
int main(void)
{
char ch;
int space_count = 0;
int linebreak_count = 0;
int other_count = 0;
while ((ch = getchar()) != '#')
{
if (ch == ' ')
space_count++;
if (ch == '
')
linebreak_count++;
if ((ch != ' ') && (ch != '
'))
other_count++;
}
printf("space is %d, line break is %d, other char is %d
",
space_count, linebreak_count, other_count);
printf("Done!
");
return 0;
}