码迷,mamicode.com
首页 > 其他好文 > 详细

UVA272 TeX括号(TEX Quotes )

时间:2017-10-06 13:02:42      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:one   while   .com   ring   一个   string   space   gif   else   

技术分享

题意:第一个"替换为``   第二个"替换为‘‘

思路:getline()读取,标记变量标记。

技术分享
 1 #include<cstdio>
 2 #include<string>
 3 #include <iostream>
 4 using namespace std;
 5 int main()
 6 {
 7     string s;
 8     int q=1;
 9     while(getline(cin,s)){
10         string :: iterator it;
11         for(it=s.begin(); it!=s.end(); it++){
12             if(*it=="){
13                 printf("%s",q ? "``" : "‘‘");    
14                 q=!q;
15             } 
16                 
17             else cout << *it;
18         }
19         cout << endl;
20     }
21     return 0;
22 }
View Code

 

UVA272 TeX括号(TEX Quotes )

标签:one   while   .com   ring   一个   string   space   gif   else   

原文地址:http://www.cnblogs.com/seaupnice/p/7631346.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!