Hydra Smith

跳到主文

Hydra Smith

部落格全站分類:心情日記

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 1月 31 週四 201314:04
  • ACM Q272 TeX Quotes

TeX 是一種由 Donald Knuth 所發展出的一套文書排版軟體。這套軟體可以將原始文件檔加上一些像字型等型態後,轉成一份很漂亮的文件。而一份漂亮的文件是需要用 `` 和 " 來把別人說的話給「引」出來,而不是用大部份鍵盤上有的 " 。雖然鍵盤裡通常不會有這種有方向的雙引號鍵,不過上面有左單引號 ` (有人叫 backquote ),和右單引號 ' (有人叫 apostrophe 或 quote )。你可以在你的鍵盤上找一下,不過要小心不要將 ` 與 \ ( backslash 鍵)搞混了。而在 TeX 裡,使用者可以輸入兩個左單引號 `` 來構成一個左雙引號 `` ,或者是兩個右單引號 '' 來構造一個右單引號 '' ,不過呢,通常大家打字時都很習慣用普通的雙引號 " 來引述別人的話。

如果原始文件檔內容是:

"To be or not to be," quoth the bard, "that is the question."

則 TeX 作出來的文件並不會是我們所想要的:

``To be or not to be," quoth the bard, ``that is the question."

為了要得到上面的文件,我們需要把原始文件變成這個樣子:

``To be or not to be,'' quoth the bard, ``that is the question.''

你現在必須要寫一個程式,將普通的雙引號("),轉成有方向性的雙引號,而其它文字則不變。而在把普通的雙引號換掉的時候,要特別注意,當要開始引述一句話時要用 `` ,而結束引述時要用 '' 。不用擔心會有多層巢狀引號的情形,也就是第一個引號一定是用 `` 來代替,再來用 '',然後用 `` ,接著用 '' ,依此類推。

 

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


很簡單不太需要看的一題


 

 

#include <stdio.h>
#include <stdlib.h>

int main()
{

 char Output[200000];
 char data;
 
 int i =0 , dot_status = 0,out_Index = 0;
 
 while(1)
 {
 if(scanf("%c",&data) == EOF) break;
 
 
 if(data == '"')
 {
 if(dot_status == 0)
 {
 Output[out_Index++] = '`'; 
 Output[out_Index++] = '`'; 
 dot_status = 1; 
 }
 else
 {
 Output[out_Index++] = '\''; 
 Output[out_Index++] = '\''; 
 dot_status = 0;
 }
 } 
 else
 {
 Output[out_Index++] = data;
 } 
 } 
 Output[out_Index++] = 0; 
 
 printf("%s",Output);

 return 0;
}
文章標籤
全站熱搜
創作者介紹
創作者 HydraSmith 的頭像
HydraSmith

Hydra Smith

HydraSmith 發表在 痞客邦 留言(0) 人氣(100)

  • 全站分類:
  • 個人分類:ACM
▲top

個人資訊

HydraSmith
暱稱:
HydraSmith
分類:
心情日記
好友:
累積中
地區:

熱門文章

  • ()Q170: Clock Patience
  • ()ACM Q272 TeX Quotes
  • ()ACM Q155: All Squares
  • ()吉他演奏曲情非得已
  • ()Q11984: A Change in Thermal Unit
  • ()Q160: Factors and Factorials
  • ()ACM 11369 Shopaholic
  • ()撲克符號
  • ()失落沙洲-完整版
  • ()20100616-20 Session Review

文章分類

toggle 程式設計 (2)
  • ACM (0)
  • 常用程式 Pack (0)
toggle 生活筆記 (1)
  • 心情 (0)
toggle 生活娛樂 (2)
  • 電影隨筆 (0)
  • 我的吉他曲 (0)
toggle Poker 區 (2)
  • Poker Session Record (0)
  • 撲克雜記 (0)
  • 未分類文章 (1)

最新文章

    最新留言

    文章精選

    文章搜尋

    誰來我家

    參觀人氣

    • 本日人氣:0
    • 累積人氣:1,016
    hydrasmith
    PIXNET Logo登入