網頁

2013年8月16日 星期五

c007: TeX Quotes、UVA 272

#include<iostream>
#include<cstdlib>
#include<string>

using namespace std ;

int main(){
    string line ;
    size_t found = 0 ;
    string quote[] = {"``", "''"} ;
    int which = 0 ;
    while(getline(cin,line,'\n')){
        found = line.find("\"") ;
        while(found != string::npos){
            line.replace(found,1,quote[which]) ;
            which ^= 1 ;
            found = line.find("\"",found+2) ;
        }
        cout << line << endl ;
    }
    return 0 ;
}

沒有留言:

張貼留言