
题意:
统计间隔在1中0的个数
思路:
超简单写法,直接利用string的find、rfind函数即可
#include<bits/stdc++.h>using namespace std;int main() {//freopen("in.txt", "r", stdin);ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);int t; cin >> t;while (t--) {string s; cin >> s;int cnt = 0;int first = s.find('1');int last = s.rfind('1');for (int i = first; i < last; i++) if (s[i] == '0')cnt++;cout << cnt << endl;}}
