fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int l = 0;
  6. int lc = 0;
  7. int lct = 0;
  8. string str = "LCCCTCLLCT";
  9. for(char ch:str){
  10. if(ch == 'L') l++;
  11. if(ch =='C') lc += l;
  12. if(ch == 'T') lct += lc;
  13. }
  14. cout<<"The number of LCT's in the string is:"<<lct<<endl;
  15. return 0;
  16. }
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
The number of LCT's in the string is:10