紫书——TEX Quotes UVA - 272

ps:改题目书上的样例写得更好orz,新手如果看不懂他写的(估计没有了)可以观察一下我的代码,意思一样


#include <cstdio>
#include <iostream>

using namespace std;


int main() {
	//freopen("in.txt","r",stdin);

	bool isl = 0;	//判断左边的单引号是否已经写了
	char tmp;

	while((tmp = getchar()) != EOF) {
		if(tmp == '"') {
			if(!isl) {
				printf("``");
				isl = 1;
			} else {
				printf("''");
				isl = 0;
			}
		} else if(tmp == '\n')
			printf("\n");
		else
			printf("%c",tmp);

	}

	return 0;
}

猜你喜欢

转载自blog.csdn.net/a673953508/article/details/80060461