swap + string + 循环语句
2023-08-25 13:59:43
发布于:上海
4阅读
0回复
0点赞
#include<iostream>
using namespace std;
int main(){
string do_it;
cin>>do_it;
int pre[5]={0,1,0,0,0};
for(int i=0;i<do_it.size();i++){
if(do_it[i]=='A') swap(pre[1],pre[2]);
else if(do_it[i]=='B') swap(pre[2],pre[3]);
else swap(pre[1],pre[3]);
}
for(int i=1;i<=3;i++){
if(pre[i]==1){
cout<<i;
return 0;
}
}
}
这里空空如也
有帮助,赞一个