#include <iostream> int n; using namespace std; string tests; int main() { cin >> n; cin >> tests; int counter = 0; for (int i = 0; i < n; i += (n/10)) { bool all_t = true; for (int j = 0; j < (n/10); j++) { if (tests[i+j] != 'T') { all_t = false; break; } } counter += (all_t ? 1 : 0); } cout << counter << endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <iostream> int n; using namespace std; string tests; int main() { cin >> n; cin >> tests; int counter = 0; for (int i = 0; i < n; i += (n/10)) { bool all_t = true; for (int j = 0; j < (n/10); j++) { if (tests[i+j] != 'T') { all_t = false; break; } } counter += (all_t ? 1 : 0); } cout << counter << endl; } |