2020-05-26 翻硬币

2020-05-26  本文已影响0人  JalorOo
#include <cstdio>
#include <iostream>
using namespace std;

string s,k;

int main(){
    ios::sync_with_stdio(false);
    cin>>s>>k;
//    cin>>s;
//    s = s.replace(5, 5, "*",1);
//    cout<<s<<endl;
    int ans = 0;
    bool f = true;
    int c = 0;
    for (int i = 0; i<s.length(); i++) {
        if (s[i]!=k[i]) {//若不相等
            if (f) {
                c = i;
                f = false;
            } else {
                ans+= (i-c);
                f = true;
            }
        }
//        printf("i:%d\n",i);
//        cout<<s<<endl;
    }
    printf("%d",ans);
    return 0;
}

上一篇 下一篇

猜你喜欢

热点阅读