藍橋杯[第四屆][B組]-翻硬幣
2022-04-04 22:54 幻霞 閱讀(48) 評論(0) 收藏 舉報
開始還覺得似乎并不太容易,但是其實這其實是一個推箱子消消樂的游戲。
#include <bits/stdc++.h> using namespace std; char s1[1005]={0}; char s2[1005]={0}; int main() { cin>>s1; cin>>s2; int ans=0; int p=0; while(p<strlen(s1)){ if(s1[p]!=s2[p]){ s1[p]=s1[p]=='*'?'o':'*'; s1[p+1]=s1[p+1]=='*'?'o':'*'; ans++; } p++; } cout<<ans; return 0; }
浙公網安備 33010602011771號