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