uva 272 - TEX Quotes

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=208

解題策略

雙引號 第一個改成「 ``」 第二個改成「''」

參考程式碼

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

#include <iostream>#include <cstring>#include <cstdio>using namespace std; int main() { bool first=true; char ch; while((ch=getchar())&&(ch != EOF)){ if ((ch=='"')&&(first)){ cout<<"``"; first=false; }else if ((ch=='"')&&(!first)){ cout<<"''"; first=true; }else { cout <<ch; } } }