[CF738A]Interview with Oleg(模拟)
题目链接:http://codeforces.com/contest/738/problem/A
题意:把ogo..ogo替换成***。
写的有点飘,还怕FST。不过还好
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int maxn = 110; 5 int n, m; 6 char s[maxn]; 7 char t[maxn]; 8 9 int main() { 10 // freopen("in", "r", stdin); 11 while(~scanf("%d", &n)) { 12 scanf("%s", s); 13 m = 0; 14 memset(t, 0, sizeof(t)); 15 for(int i = 0; s[i]; i++) { 16 if(s[i] == 'o') { 17 int j = i; 18 while(1) { 19 if(s[j+1] == 'g' && s[j+2] == 'o') j += 2; 20 else break; 21 } 22 if(j != i) { 23 t[m++]='*'; t[m++]='*'; t[m++]='*'; 24 i = j; 25 } else t[m++] = s[i]; 26 } else t[m++] = s[i]; 27 } 28 puts(t); 29 } 30 return 0; 31 }