#include <string> #include <iostream> using namespace std; int main(){ int n,wynik=0; cin >> n; string in; cin >> in; int m=n/10; for (int i=0; i<n;){ int tmp=0; for(int j = i+m; j>i; i++){ if (in[i]=='T') tmp++; } if (tmp==m) wynik++; } cout << wynik; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <string> #include <iostream> using namespace std; int main(){ int n,wynik=0; cin >> n; string in; cin >> in; int m=n/10; for (int i=0; i<n;){ int tmp=0; for(int j = i+m; j>i; i++){ if (in[i]=='T') tmp++; } if (tmp==m) wynik++; } cout << wynik; } |