`
hellobin
  • 浏览: 65484 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

UVA 272 - TEX Quotes

    博客分类:
  • UVA
 
阅读更多

 

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 `` and " 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 and Output

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. 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!''

 

 

 

#define RUN
#ifdef RUN


#include <stdio.h>
int main() {
  int c, q = 1;

  while((c= getchar()) != EOF) {
    if(c == '"') {
		printf("%s", q ? "``" : "''");
		q = !q;
    }
    else
		printf("%c", c);
  }
  return 0;
}


#endif



分享到:
评论

相关推荐

    uva272 uva272 uva272

    标题中的"uva272 uva272 uva272"和描述中的"uva272"指的是UVA(University of Virginia)在线判题系统的第272题,这通常与编程竞赛和算法挑战有关。该题目的标签为"算法",意味着我们需要解决一个与计算机算法设计和...

    股票行情查看 - Stock quotes_v1.0.6.crx

    股票行情查看 - Stock quotes_v1.0.6.crx

    New Office - Analyst Quotes (Dec 2012).pptx

    New Office - Analyst Quotes (Dec 2012).pptx

    前端开源库-coffeelint-prefer-double-quotes

    在`coffeelint-prefer-double-quotes-master`这个压缩包中,可能包含以下内容: 1. `README.md`:项目介绍和使用指南。 2. `lib/` 目录:包含了实现`prefer_double_quotes`规则的源代码。 3. `test/` 目录:测试用例...

    PyPI 官网下载 | flake8-single-quotes-0.1.0.tar.gz

    《PyPI官网下载:flake8-single-quotes-0.1.0.tar.gz——Python代码风格检查工具解析》 在Python编程领域,保持代码的一致性和规范性至关重要,这有助于提高代码可读性和团队协作效率。PyPI(Python Package Index...

    前端开源库-typographic-quotes

    开源库“typographic-quotes”正是针对这一需求而设计的,它专注于提供优雅、规范的引号处理方案,确保在网页上始终使用正确的典型大引号。本文将深入探讨这个库的功能、使用方法以及其在实际项目中的应用。 ...

    前端开源库-typographic-quotes-l10n-db

    "前端开源库-typographic-quotes-l10n-db"是一个专注于排版和国际化(l10n)的开源项目,特别是针对引号的处理。这个库的核心在于提供了一套完整的、全球化支持的排版引号数据库。 排版引号,也被称为智能引号或...

    1-Click Quotes Search-crx插件

    "1-Click Quotes Search-crx插件"是一个专为英语用户设计的浏览器扩展程序,它允许用户快速便捷地访问和搜索全球最大的引言数据库。这个插件的核心功能是提供一个简单的一键式搜索机制,帮助用户在浏览网页时即时...

    to-single-quotes-cli:将匹配的双引号转换为单引号

    单引号cli 将匹配的双引号转换为单引号: I "love" unicorns → I 'love' unicorns安装$ npm install --global to-single-quotes-cli用法$ to-single-quotes --help Usage $ to-single-quotes &lt;string&gt; $ echo ...

    javascript-forex-quotes:JavaScript库,用于获取实时外汇报价

    javascript-forex-quotes javascript-forex-quotes是用于获取实时外汇报价的Javascript库。 目录 要求 您可以从获得1Forge API密钥 安装 npm install forex-quotes --save 用法 导入客户端 // With require const...

    movie-quotes:获取热门电影报价

    安装 $ npm install --save movie-quotes用法 const movieQuotes = require ( 'movie-quotes' ) ;movieQuotes . random ( ) ;//=&gt; 'Max'应用程序接口。全部类型: array 根据 AFI 排名前 100 名的最佳电影名言。。...

    Popular-Movie-quotes:一个简单的NPM程序包,用于返回流行电影的报价

    入门$ npm i popular-movie-quotes --save安装 这是通过提供的模块。 在安装之前,请 使用命令完成 : $ npm i popular-movie-quotes --save用法 getAll()方法返回一个对象数组,每个对象包含quote和movie 。 { ...

    PHP库,用于获取实时外汇报价。-PHP开发

    php-forex-quotes php-forex-quotes是一个PHP库,用于获取实时外汇报价。 请参阅/ examples文件夹中的REST和WebSocket实现示例。 目录要求安装php-forex-quotes php-forex-quotes是一个PHP库,用于获取实时外汇报价...

    Rocket-Loader-master_quotes_EveryDay_源码

    "Rocket-Loader-master_quotes_EveryDay_源码"是一个与编程相关的项目,主要目标是每天加载和展示引言(quotes)。这个项目可能是一个Web应用或者一个桌面应用,它设计了一个功能,让用户每天都能看到新的引言,从而...

    to-double-quotes-cli:将匹配的单引号转换为双引号

    $ npm install --global to-double-quotes-cli 用法 $ to-double-quotes --help Usage $ to-double-quotes $ echo &lt;string&gt; | to-double-quotes Example $ to-double-quotes "I love 'unicorns'" I love ...

    Yahoo-Finance-Stock-Quotes:一个个性化的应用程序,用于从雅虎金融部门获取跨国公司的股票报价

    "Yahoo-Finance-Stock-Quotes" 是一个专为此目的设计的个性化应用程序,它允许用户方便地从雅虎金融部门获取全球各大公司的股票数据。这款应用以其简洁的用户界面(UI)和可扩展性,为用户提供了直观且高效的股票...

    programming-quotes-api:用于开源项目的Programming Quotes API

    用于开源项目的Programming Quotes API。 主页: Github: API文档 支持的语言:en,sr。 公共路线 GET (获取所有报价) GET (按语言获取报价) GET (按页获取报价) GET (获得随机报价) GET (按语言...

    股票行情查看 - Stock quotes-crx插件

    语言:中文 (简体) 股票行情指数查看工具,上证,A股,港股,K线 股票行情查看,支持沪深股市A股实时股票信息,实时成交价格,沪深指数等等-------- v1.0.6 2021-2-27 --------1、修复搜索网络问题2、有任何问题与...

    sun-tzu-quotes:《孙子兵法》中的一些《孙子兵语》

    安装npm install sun-tzu-quotes [--g | --save]例子该模块包含在API和CLI中。 代码示例: var sunTzu = require ( 'sun-tzu-quotes' )// random quoteconsole . log ( sunTzu ( ) )//=&gt; 'All warfare is based on ...

    crazy-quotes-front-end:C3L Crazy-Quotes 项目的前端部分

    9. **版本控制**:项目名称中的 "crazy-quotes-front-end-master" 提示我们,开发者可能使用了 Git 进行版本控制,便于团队协作和项目管理。 以上是对C3L Crazy-Quotes 项目前端部分可能涉及的一些关键技术点的概述...

Global site tag (gtag.js) - Google Analytics