UVA 272 TEX Quotes(字符串处理)

这道题看的刘汝佳紫书的代码,感觉字符串处理用这个方式很好,留下来当模板
不能用gets()可以选择getchar()进行替代
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<time.h>
using namespace std;
int main()
{
    char c, q = 1;
    while((c = getchar())!=EOF)
    {
        if(c == '"'){
            printf("%s",q ? "``" : "''");
            q = !q;
        }
        else printf("%c",c);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41444888/article/details/80500255
TEX