POJ 1488 Tex Quotes --- 水题

  POJ 1488

  题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' )

  解题思路:水题,设置一个bool变量标记是左引号还是右引号即可

/* POJ 1488 Tex Quotes --- 水题 */
#include <cstdio>
#include <cstring>

int main()
{
#ifdef _LOCAL
    freopen("D:\input.txt", "r", stdin);
#endif

    char c;
    bool flag = 0;
    while ((c = getchar()) != EOF) {
        if ('"' == c){
            printf("%s", flag ? "''" : "``");
            flag = !flag;
        }
        else{
            putchar(c);
        }
    }

    return 0;
}
View Code
原文地址:https://www.cnblogs.com/tommychok/p/5309227.html