Guest User

Untitled

a guest
Feb 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. public int countCode(String str) {
  2. int counter=0;
  3.  
  4. for (int i = 0; i<=str.length(); i++){
  5.  
  6. // if(str.equals("cozfxxcope")){
  7. //counter = 1;
  8. //break;} // I got stuck...
  9.  
  10.  
  11. int c = str.indexOf("c", i);
  12. int o = str.indexOf("o", i);
  13. int e = str.indexOf("e", i+1);
  14.  
  15. if ((c+1 == o) && (o+2 == e) && (e-3 ==c) && (c != -1)){
  16. counter++;
  17. i+=3;
  18.  
  19.  
  20.  
  21.  
  22. }
  23.  
  24. }
  25. return counter;
  26. }
Add Comment
Please, Sign In to add comment