#include <iostream> using namespace std; int main() { int n, points = 0, group = 0; string results; cin >> n; if ((n < 10) || (n > 100)){ throw "The number of tests must be between 10 and 100"; } if (n % 10 != 0){ throw "The number of tests must be divisible by 10"; } cin >> results; if (results.size() != n){ throw "Incorrect results"; } int single_group = n/10; while (group < n){ for(int i = 0; i < single_group; i++){ if (results[single_group * group + i] != 'T'){ break; } else if (i == single_group - 1){ points++; } } group++; } cout << points; }
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 30 31 32 33 34 | #include <iostream> using namespace std; int main() { int n, points = 0, group = 0; string results; cin >> n; if ((n < 10) || (n > 100)){ throw "The number of tests must be between 10 and 100"; } if (n % 10 != 0){ throw "The number of tests must be divisible by 10"; } cin >> results; if (results.size() != n){ throw "Incorrect results"; } int single_group = n/10; while (group < n){ for(int i = 0; i < single_group; i++){ if (results[single_group * group + i] != 'T'){ break; } else if (i == single_group - 1){ points++; } } group++; } cout << points; } |