1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| #include <iostream> using namespace std; int T; int n; int x; int main() { cin >> T; while (T--) { cin >> n; int flag = 0, cnt = 0, ans = 0; for (int i = 0; i < n; ++i) { cin >> x; if (x) { if (!flag) ++flag; else { ans += cnt; cnt = 0; } } else if (flag) { ++cnt; } } cout << ans << endl; } return 0; }
|