UVA272--TEX Quotes【字串】
阿新 • • 發佈:2018-12-19
TEX Quotes
題目大意:將輸入字串中的所有對雙引號的做雙引號改為 `` ,右雙引號改為 '' 。
解決方法:遍歷一遍及時修改即可。
AC程式碼:
#include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <map> #include <stack> #include <queue> #include <vector> #include <bitset> #include <set> #include <utility> using namespace std; typedef long long ll; #define inf 0x3f3f3f3f #define rep(i,l,r) for(int i=l;i<=r;i++) #define lep(i,l,r) for(int i=l;i>=r;i--) #define ms(arr) memset(arr,0,sizeof(arr)) //priority_queue<int,vector<int> ,greater<int> >q; const int maxn = (int)1e5 + 5; const ll mod = 1e9+7; int main() { //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); ios::sync_with_stdio(0),cin.tie(0); int c; int ju=1; //判斷是否是第一次出現 while((c=getchar())!=EOF) { if(c==(int)'"') { if(ju) { printf("``"); ju=0; } else { printf("''"); ju=1; } } else printf("%c",c); } return 0; }