fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. string s="LMCT";
  7. int countL=0;
  8. int countLC=0;
  9. int countLCT=0;
  10. for(int i=0;i<s.size();i++){
  11. if(s[i]=='L'){
  12. countL++;
  13. }
  14. if(s[i]=='C'){
  15. countLC=countL+countLC;
  16. }
  17. if(s[i]=='T'){
  18. countLCT=countLC+countLCT;
  19.  
  20. }
  21. }
  22. cout<<countLCT;
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
1