UVa 272 - TEX Quotes

来源:互联网 发布:室内平面设计软件下载 编辑:程序博客网 时间:2024/05/17 06:38

时间限制:3.000秒

题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=829&page=show_problem&problem=208


  入门水题之一。

  题目大意就是读入文本,要求把其中的英文双引号转换成对应的格式。英文双引号前后是没有区别的,而转换之后的双引号则是 ``' '的格式,所以需要特判一下。

#include <iostream>#include <string>using namespace std;int main() {    string line;    int t = 1;    while(getline(cin, line)) {        for(string::iterator it = line.begin(); it != line.end(); ++it) {            if(*it == '"') {                if(t) cout << "``";                else cout << "''";                t = !t;            } else cout << *it;        }        cout << endl;    }}


0 0
原创粉丝点击