poj 1488 TEX Quotes

来源:互联网 发布:淘宝双十一背景音乐 编辑:程序博客网 时间:2024/05/29 11:50
//这题主要是两种左右引号比较难分清楚,只要将样例的copy下来,再通过键盘的尝试就容易得出! #include <iostream>#include <string>using namespace std;int main(){    int len, i;    string str;    bool flag = true;     while (getline(cin, str)){          len = str.length();          for (i = 0; i < len; i++){              if (str[i] == '"' && flag == true){                   cout << "``";                  flag = false;               }               else if (str[i] == '"' && flag == false){                   cout << "''";                   flag = true;               }               else                  cout << str[i];          }          cout << endl;    }        system("pause");}/*"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!"``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!'' */

原创粉丝点击