每日一题07_翻硬币

Posted on 2020-07-30 15:09  Nicela  阅读(82)  评论(0)    收藏  举报

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=105;
char chu[N],zhong[N];
int step;
void turn(int x)
{
if(chu[x]=='*')
{
chu[x]='o';
}
else
{
chu[x]='*';
}
}
int main()
{
cin>>chu>>zhong;
int num=strlen(zhong);
for(int i=0;i<num;i++)
{
if(chu[i]!=zhong[i])
{
step++;
turn(i);
turn(i+1);
}
}
cout<<step;
return 0;
}

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3