7.12.4

# 7.12.4
#include <stdio.h>
int main(void)
{
    int Exclamationtoperiod = 0;  // 感叹号替换句号次数
    int two2one = 0;              // 两个感叹号替换一个感叹号次数
    char ch;

    while ((ch = getchar()) != '#')
    {
        if (ch == '.')
        {
            putchar('!');
            ++Exclamationtoperiod;
        }
        else if (ch == '!')
        {
            putchar('!');
            putchar('!');
            ++two2one;
        }
        else
            putchar(ch);
    }

    printf("
替换了%d次
", two2one + Exclamationtoperiod);

    return 0;
}

让我没想到的是getchar(),putchar()对中文支持的是这么好,原样输入原样输出。

原文地址:https://www.cnblogs.com/EisNULL/p/10762561.html