include iostream include string int main std string str TFFTFFT int co

 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 <string>
int main() {
std::string str("TFFTFFT");
int countT = 0;
int countF = 0;
int reF = 0;
int reT = 0;
for(int i=0; i!=str.length(); i++) {
if(str[i] == 'T') {
countT++;
if(countF > 1) {
reF++;
}
countF = 0;
} else if (str[i] == 'F') {
countF++;
if(countT > 1) {
reT++;
}
countT = 0;
}
}
std::cout<<reF<<"F"<<reT<<"T";
return 0;
}