272 - TEX Quotes (UVA)

题目链接如下:

Online Judge

我的代码如下:

#include 
#include 

int main(){
    std::string s;
    bool flag = true;
    while(getline(std::cin, s)){
        for(int i = 0; i < s.size(); ++i){
            if(s[i] == '"'){
                if(flag){
                    printf("``");
                    flag = false;
                } else{
                    printf("''");
                    flag = true;
                }
            } else{
                printf("%c", s[i]);
            }
        }
        printf("\n");
    }
    return 0;
}

你可能感兴趣的:(UVA,算法)