poj 1488 TEX Quotes 【水题】
来源:互联网 发布:淘宝去年的交易记录 编辑:程序博客网 时间:2024/05/29 11:05
TEX Quotes
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 9671 Accepted: 5070
Description
TEX is a typesetting language developed by Donald Knuth. It takes source text together with a few typesetting instructions and produces, one hopes, a beautiful document. Beautiful documents use double-left-quote and double-right-quote to delimit quotations, rather than the mundane " which is what is provided by most keyboards. Keyboards typically do not have an oriented double-quote, but they do have a left-single-quote ` and a right-single-quote '. Check your keyboard now to locate the left-single-quote key ` (sometimes called the "backquote key") and the right-single-quote key ' (sometimes called the "apostrophe" or just "quote"). Be careful not to confuse the left-single-quote ` with the "backslash" key \. TEX lets the user type two left-single-quotes `` to create a left-double-quote and two right-single-quotes '' to create a right-double-quote. Most typists, however, are accustomed to delimiting their quotations with the un-oriented double-quote ".
If the source contained
"To be or not to be," quoth the bard, "that is the question."
then the typeset document produced by TEX would not contain the desired form: "To be or not to be," quoth the bard, "that is the question." In order to produce the desired form, the source file must contain the sequence:
``To be or not to be,'' quoth the bard, ``that is the question.''
You are to write a program which converts text containing double-quote (") characters into text that is identical except that double-quotes have been replaced by the two-character sequences required by TEX for delimiting quotations with oriented double-quotes. The double-quote (") characters should be replaced appropriately by either `` if the " opens a quotation and by '' if the " closes a quotation. Notice that the question of nested quotations does not arise: The first " must be replaced by ``, the next by '', the next by ``, the next by '', the next by ``, the next by '', and so on.
If the source contained
"To be or not to be," quoth the bard, "that is the question."
then the typeset document produced by TEX would not contain the desired form: "To be or not to be," quoth the bard, "that is the question." In order to produce the desired form, the source file must contain the sequence:
``To be or not to be,'' quoth the bard, ``that is the question.''
You are to write a program which converts text containing double-quote (") characters into text that is identical except that double-quotes have been replaced by the two-character sequences required by TEX for delimiting quotations with oriented double-quotes. The double-quote (") characters should be replaced appropriately by either `` if the " opens a quotation and by '' if the " closes a quotation. Notice that the question of nested quotations does not arise: The first " must be replaced by ``, the next by '', the next by ``, the next by '', the next by ``, the next by '', and so on.
Input
Input will consist of several lines of text containing an even number of double-quote (") characters. Input is ended with an end-of-file character.
Output
The text must be output exactly as it was input except that:
- the first " in each pair is replaced by two ` characters: `` and
- the second " in each pair is replaced by two ' characters: ''.
Sample Input
"To be or not to be," quoth the Bard, "thatis the question".The programming contestant replied: "I must disagree.To `C' or not to `C', that is The Question!"
Sample Output
``To be or not to be,'' quoth the Bard, ``thatis the question''.The programming contestant replied: ``I must disagree.To `C' or not to `C', that is The Question!''
题意:给定一些字符串,修改串中所有的'"'字符,交替修改为字符'``'和字符' '' '。
AC代码:
#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <algorithm>#include <queue>#include <stack>#include <map>#include <set>#include <vector>#define INF 0x3f3f3f#define eps 1e-4#define MAXN (100+10)#define MAXM (100000)#define Ri(a) scanf("%d", &a)#define Rl(a) scanf("%lld", &a)#define Rf(a) scanf("%lf", &a)#define Rs(a) scanf("%s", a)#define Pi(a) printf("%d\n", (a))#define Pf(a) printf("%.2lf\n", (a))#define Pl(a) printf("%lld\n", (a))#define Ps(a) printf("%s\n", (a))#define W(a) while(a--)#define CLR(a, b) memset(a, (b), sizeof(a))#define MOD 1000000007#define LL long long#define lson o<<1, l, mid#define rson o<<1|1, mid+1, r#define ll o<<1#define rr o<<1|1using namespace std;int main(){ char op; bool flag = true; while(scanf("%c", &op) != EOF) { if(op == '\"') { if(flag) printf("``"); else printf("''"); flag = !flag; }// else if(op == '``' && flag % 2 == 0)// {// printf("""");// flag = 1// } else printf("%c", op); } return 0;}
0 0
- poj 1488 TEX Quotes 【水题】
- POJ 1488 TEX Quotes
- [POJ]1488 TEX Quotes
- POJ 1488 TEX Quotes
- poj 1488 TEX Quotes
- poj 1488 TEX Quotes
- POJ-1488TEX Quotes
- POJ 1488 TEX Quotes
- poj 1488 TEX Quotes
- POJ 1488 TEX Quotes
- POJ 1488 - TEX Quotes
- poj 1488 TEX Quotes 字符串(水题)
- poj--1488--TEX Quotes(水题)
- poj 1488 TEX Quotes(水题)
- POJ 1488: TEX Quotes 题解
- POJ - 1488 - TEX Quotes (字符串!)
- POJ 1488:TEX Quotes【字符串】
- POJ 1488 TEX Quotes 笔记
- 郑大校赛总结
- 3D数学总结
- Android Handler
- hdu 1034 Candy Sharing Game【水题 模拟】
- centos安装caffe python接口时候可能出现错误
- poj 1488 TEX Quotes 【水题】
- 为什么要使用内部类??以及内部类大汇总!!面试必备!!
- 默克尔赠送中国桑叶地图用意何在?
- 测试测试
- sql 对Date的转换
- 反向代理实现nginx+apache动静分离
- android两种方式实现离线缓存
- ecshop支付宝前台付款后台不显示已付
- 完美解决:VS2015与VS2010同时安装后,头文件无法识别的问题