fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve() {
  5. string s; cin >> s;
  6. int out = 1;
  7. for (int i = 0; i < s.length()-1; i++) {
  8. out += (s[i]>s[i+1]);
  9. }
  10. cout << out << "\n";
  11. }
  12.  
  13. int main() {
  14. int count; cin >> count;
  15. for (int i=0; i<count; i++) { solve(); }
  16. }
  17.  
Success #stdin #stdout 0.01s 5316KB
stdin
6
11010
00000000
1
10
0001111
0110
stdout
3
1
1
2
1
2