#include <iostream> using namespace std; int main() { int z,dl; int dw = 0; int pun = 0; int podw = 0; string ciag; cin >> z >> ciag; dl = ciag.length(); z = z / 10; for (int i=0; i < dl; i++) { dw++; if (ciag[i] == 'T'&& podw==z-1) { pun++; dw = 0; podw = 0; } else if (ciag[i] == 'T') { podw++; } if (dw == z) { dw = 0; podw = 0; } } cout << pun; }
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 27 28 | #include <iostream> using namespace std; int main() { int z,dl; int dw = 0; int pun = 0; int podw = 0; string ciag; cin >> z >> ciag; dl = ciag.length(); z = z / 10; for (int i=0; i < dl; i++) { dw++; if (ciag[i] == 'T'&& podw==z-1) { pun++; dw = 0; podw = 0; } else if (ciag[i] == 'T') { podw++; } if (dw == z) { dw = 0; podw = 0; } } cout << pun; } |