You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
995 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
int main() {
/*
:
,
,
:,'1',.
*/
//cin读入优化
std::ios::sync_with_stdio(false);
string s;
int ans = 0;
cin >> s; //字符串输入
for (int i = 1; i < s.size(); i++) {
if (s[i] != s[i - 1]) ans++; //碰到不一样的就反转一下
}
if (s[s.size() - 1] == '0') cout << ans + 1; // 最后要特判一下 如果最后的是 0 还要多翻一次
else cout << ans; //不是0的话直接输出就好
return 0; //完结撒花。。。,洛谷专用
}