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. kali linux安装搜狗输入法

    1. 更新软件源 vi /etc/apt/sources.list 2. 安装fcitx apt-get install fcitx 3. 下载deb包到指定目录, dpkg -i sogou**** ...

  2. 图像分类丨Inception家族进化史「GoogleNet、Inception、Xception」

    引言 Google提出的Inception系列是分类任务中的代表性工作,不同于VGG简单地堆叠卷积层,Inception重视网络的拓扑结构.本文关注Inception系列方法的演变,并加入了Xcept ...

  3. FloatHelper

    function FloatHelper() { } FloatHelper.prototype.showFloater = function (Target, Title, Action, Acti ...

  4. Home is where your heart is

    Home is where your heart is.心之所在即为家.

  5. allure使用简介

    #安装依赖包pip install requests_toolbeltpip install pyyamlpip install pytest-allure-adaptor #安装allure2 说明 ...

  6. Linux上通过MySQL命令访问MySQL数据库时常见问题汇总

    Linux上通过mysql命令访问MySQL数据库时常见问题汇总 1)创建登录账号 #创建用户并授权 #允许本地访问 create user 'test'@'localhost' identified ...

  7. centos上手动安装最新版本ELK

    软件包下载地址:https://www.elastic.co/downloads/elasticsearch 1,安装es #tar zxvf elasticsearch-2.3.4.tar.gz # ...

  8. 51nod 1191 消灭兔子

    题目来源: 2013腾讯马拉松赛第三场 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 有N只兔子,每只有一个血量B[i],需要用箭杀死免子.有M种不同类型的箭可以 ...

  9. 洛谷 P2868 [USACO07DEC]观光奶牛Sightseeing Cows

    题目描述 Farmer John has decided to reward his cows for their hard work by taking them on a tour of the ...

  10. C基础的练习集及测试答案(31-39)

    31.读懂以下程序,说明程序的功能#include<stdio.h>int main(){ int m,n,r,m1,m2; printf("请输入2个正整数:"); ...