UVa 272 Tex Quotes --- 水题

  题目大意:在TeX中,左引号是 ``,右引号是 ''。输入一篇包含双引号的文章,你的任务是把他转成TeX的格式

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

/* UVa 272 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/5335088.html