#include <iostream> #include<cstring> using namespace std; #define MAXSIZE 100 int main() { int n; char s[MAXSIZE]; cin >> n; cin >> s; int ngr = n / 10; int ps = 0, tnum = 0; for (int i = 0; i < 10; i++) { int prop = 0; for (int j = 0; j < ngr; j++) { if (s[tnum] == 'T') prop++; tnum++; } ps += prop / ngr; } cout << ps << endl; // system("pause"); }
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 29 | #include <iostream> #include<cstring> using namespace std; #define MAXSIZE 100 int main() { int n; char s[MAXSIZE]; cin >> n; cin >> s; int ngr = n / 10; int ps = 0, tnum = 0; for (int i = 0; i < 10; i++) { int prop = 0; for (int j = 0; j < ngr; j++) { if (s[tnum] == 'T') prop++; tnum++; } ps += prop / ngr; } cout << ps << endl; // system("pause"); } |