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)