A102286.雾港城的开关
2026-02-03 20:36:11
发布于:浙江
5阅读
0回复
0点赞
#include<bits/stdc++.h>//用万能头文件是一个好习惯
#define ll long long//初学者不用写
using namespace std;//命名空间
int main(){//主函数
ios::sync_with_stdio(false);//初学者只要知道这叫输入输出保底
cin.tie(0);
cout.tie(0);
int n,k=1,cnt=0;//如题意定义
char c;//定义
cin>>n;//输入
for(int i=1;i<=n;i++){//n次循环
cin>>c;//输入
if(k==-1){//运用"异或"特性
if(c=='0'){
c='1';
}
else{
c='0';
}
}
if(c=='1'){//反转
k*=-1;
cnt++;
}
}
cout<<cnt;//输出
return 0;//好习惯
}
这里空空如也








有帮助,赞一个