UVA - 272 TEX Quotes

//入门经典P47 水题
#include <cstdio>
int main()
{
	int c, q = 1;
	while ((c = getchar()) != EOF)
	{
		if (c == '"')
		{
			printf("%s", q?"``":"''");
			q = 1 - q;
		}
		else printf("%c", c);
		
	}
	return 0;
}
/*
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int c, j = 1;
	while ((c = getchar()) != EOF)
	{
		if (c == '"')
		{
			cout << (j?"``":"''");
			j = !j;
		}
		else
		cout << (char)c;
	}
	return 0;
}
*/

posted @ 2017-09-02 11:21  mofushaohua  阅读(137)  评论(0编辑  收藏  举报