TEX Quotes
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 9674   Accepted: 5073

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. 

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, "that
is 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, ``that
is the question''.
The programming contestant replied: ``I must disagree.
To `C' or not to `C', that is The Question!''
题解:要输入一行再输出一行,这样比较好,另外"竟然是两个''无语,错了半天。。。。
代码:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define PI(x) printf("%d",x)
#define PL(x) printf("%lld",x)
#define P_ printf(" ")
#define T_T while(T--)
typedef long long LL;
const int INF=0x3f3f3f3f;
char s[1000010];
int main(){
int cnt=0;
while(gets(s)){
int len=strlen(s);
for(int k=0;k<len;k++){
if(s[k]=='"'){
cnt++;
if(cnt&1)printf("``");
else printf("''");
}
else printf("%c",s[k]);
}
printf("\n");
}
return 0;
}

  

TEX Quotes(字符串,水)的更多相关文章

  1. UVa 272 Tex Quotes --- 水题

    题目大意:在TeX中,左引号是 ``,右引号是 ''.输入一篇包含双引号的文章,你的任务是把他转成TeX的格式 解题思路:水题,定义一个变量标记是左引号还是右引号即可 /* UVa 272 Tex Q ...

  2. POJ 1488 Tex Quotes --- 水题

    POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...

  3. Uva272.TEX Quotes

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  4. UVA 272 TEX Quotes

    TEX Quotes 题意: 变引号. 题解: 要想进步,真的要看一本好书,紫书P45 代码: #include<stdio.h> int main() { int c,q=1; whil ...

  5. 【UVA272】TEX Quotes

    A - TEX Quotes Time Limit:3000MS    Memory Limit:0KB    64bit IO Format:%lld & %llu Submitcid=80 ...

  6. 1222: FJ的字符串 [水题]

    1222: FJ的字符串 [水题] 时间限制: 1 Sec 内存限制: 128 MB 提交: 92 解决: 20 统计 题目描述 FJ在沙盘上写了这样一些字符串: A1  =  “A” A2  =   ...

  7. 1001 字符串“水”题(二进制,map,哈希)

    1001: 字符串“水”题 时间限制: 1 Sec  内存限制: 128 MB提交: 210  解决: 39[提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串(1<=n<= ...

  8. poj--1488--TEX Quotes(水题)

    TEX Quotes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9672   Accepted: 5071 Descri ...

  9. UVA 272 TEX Quotes【字符串】

    https://vjudge.net/problem/UVA-272 [分析]:标记一下. [代码]: #include <bits/stdc++.h> using namespace s ...

随机推荐

  1. System类基础

    取时间差: public class SystemDemo01 {     public static void main(String[] args) {         long startTim ...

  2. 面试题之 query转为obj

    要注意处理编码后的字串  对于a=123要得到number形的值 function parseQueryString(url) { var obj = {}; var query = url.sear ...

  3. 深信服模式(先做减法,必须拜访客户三次、研究需求方向,把产品的问题控制住,快速反应,在未来十年,绝大部分业务都会搬到Internet上来,实现All on Internet)good

    深圳市盛凯信息科技有限公司与深信服合作多年,可以说是看着深信服“飞速”长大的.盛凯的总经理邓渊在采访中笑言:“他们(深信服)发展得太快,而我们发展得太慢.” 深信服的产品线已从最初只有VPN一条,到目 ...

  4. 有感于NC的强大

    第一次知道nc(netcat)是好几年前的事了,那个时候天比现在更蓝,草比现在更绿,卤煮也还是一个刚上大学不久的青葱骚年... 现在把这个01年的老古董拿出来说好像有点炒冷饭的意思,资料也铺天盖地了说 ...

  5. CURD 例子

    public function modify(){ $id=$_GET['id']; $m=M('user'); $arr=$m->find($id); //var_dump($arr); $t ...

  6. VS2010/MFC对话框:消息对话框

    消息对话框 我们在使用Windows系统的过程中经常会见到消息对话框,提示我们有异常发生或提出询问等.因为在软件开发中经常用到消息对话框,所以MFC提供了两个函数可以直接生成指定风格的消息对话框,而不 ...

  7. python学习(序章)

    好久没写过笔记了,最近听说写博客笔记能使知识记忆更深刻,于是就开始写写,不为推广,只为增加记忆.好了,开始python的学习: 学习一门语言的快慢,与人无关,主要是与学习的目的有关,python语言目 ...

  8. SQL Server索引进阶:第十级,索引内部结构

    原文地址: Stairway to SQL Server Indexes: Level 10,Index Internal Structure 本文是SQL Server索引进阶系列(Stairway ...

  9. js兼容性大全

    js有个第二定律好的属性/选择器一定不兼容/* 获取类名通用代码*/function getClassName(){ if(document.getElementsByClassName){ doso ...

  10. html文件引入其它html文件的几种方法:include方式

    可以在一个html的文件当中读取另一个html文件的内容吗?答案是确定的,而且方法不只一种,在以前我只会使用iframe来引用,后来发现了另外的几种方法,那今天就总结这几种方法让大家参考一下. 1.I ...