TEX Quotes

Time Limit: 1000MS

Memory Limit: 10000K

Total Submissions: 9385

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 toC’, 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!”


解题心得:

  1. 题意就是让你将字符串中的英文的双引号改成类似于中文的双引号(并不是中文双引号),很简单,但是要注意一点就是双引号是具有方向的。
  2. 然后就是读入问题,其实可以使用getline来对string类型的进行读入,getline可以读入空格,在遇到回车的时候停止读入,很好用的,读入的格式如下
#include<string>//这个是getline 的头文件
string str;
getline(cin,str);

代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
string s;
int main()
{
bool flag = false;
//用来进行左右双引号的区分
while(getline(cin,s))
{
int len = s.length();
for(int i=0;i<len;i++)
{
if(s[i] == '"')
{
if(!flag)
printf("``");
else
printf("''");
flag = !flag;
}
else
printf("%c",s[i]);
}
printf("\n");
}
return 0;
}

库函数的使用:POJ1488-TEX Quotes(getline()的使用)的更多相关文章

  1. Uva272.TEX Quotes

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

  2. UVa 272 Tex Quotes --- 水题

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

  3. POJ 1488 Tex Quotes --- 水题

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

  4. UVA 272 TEX Quotes

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

  5. TEX Quotes(字符串,水)

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

  6. 【UVA272】TEX Quotes

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

  7. Uva - Uva272 - TEX Quotes

    TeX is a typesetting language developed by Donald Knuth. It takes source text together with a few ty ...

  8. POJ 1488 - TEX Quotes

    Description TEX is a typesetting language developed by Donald Knuth. It takes source text together w ...

  9. uva 272 Tex中的引号(Tex Quotes)

    TeX is a typesetting language developed by Donald Knuth. It takes source text together with a few ty ...

随机推荐

  1. Codeforces Round #377 (Div. 2) E. Sockets

    http://codeforces.com/contest/732/problem/E 题目说得很清楚,每个电脑去插一个插座,然后要刚好的,电脑的power和sockets的值相同才行. 如果不同,还 ...

  2. Unity3d Attribute 总结(转)

      举两个例子,在变量上使用[SerializeFiled]属性,可以强制让变量进行序列化,可以在Unity的Editor上进行赋值. 在Class上使用[RequireComponent]属性,就会 ...

  3. jsp使用中$的符号使用失效

    解决方法 添加一段话  <%@ page isELIgnored="false"%> 原因:因为jsp servlet版本问题,2.3及2.3之前的版本isELIgno ...

  4. 通过Maven构建打包Spring boot,并将config配置文件提取到jar文件外

    如果通过不同的IDE打包,着实会觉得依赖性太大,并且容易出现错误,操作也比较复杂 同时,spring-boot-maven-plugin的使用感觉,相关配置太少,并且无法满足方便部署和运行的需求. 这 ...

  5. springBoot jpa 表单关联查询

    1.创建两个实体类 import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.per ...

  6. windows下vue-cli及webpack 构建网站(一)环境安装

    1.安装Node.js,node.js安装包及源码下载地址为:https://nodejs.org/en/download/. 2.安装npm,由于新版的nodejs已经集成了npm,所以之前npm也 ...

  7. freebsd问题

    http://community.spiceworks.com/topic/91708-server-freezes

  8. ASP.NET WebForm & MongoDB

    ASP.NET WebForm & MongoDB 最近在朋友介绍下,也跟着看AngularJS 买了一本三合一的书,Node.JS+MongoDB+AngularJS http://www. ...

  9. python基础教程总结15——5 虚拟茶话会

    聊天服务器: 服务器能接受来自不同用户的多个连接: 允许用户同时(并行)操作: 能解释命令,例如,say或者logout: 容易拓展 套接字和端口: 套接字是一种使用标准UNIX文件描述符(file ...

  10. CF Gym 100187M Heaviside Function(二分)

    题意:给你一个函数和一些系数,给你一堆询问,求函数值. 根据s的符号,分成两组讨论,函数值与比x小的系数数量有关,二分输出答案. #include<cstdio> #include< ...