AcWiing 翻硬币

 

 弱化版的费解的开关。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const int N = 110; 
 4 char a[N], b[N];
 5 void turn(int i) {
 6     if (a[i] == '*') {
 7         a[i] = 'o';
 8     } else {
 9         a[i] = '*';
10     }
11 }
12 int main() {
13     cin >> a >> b;
14     int n = strlen(a);
15     int ans = 0;
16     for (int i = 0; i < n - 1; i++) {
17         if (a[i] != b[i]) {
18             turn(i);
19             turn(i + 1);
20             ans++;
21         }
22     }
23     cout << ans << endl;
24     return 0;
25 }

 

posted @ 2020-04-27 11:26  kyk333  阅读(162)  评论(0)    收藏  举报