Vajad kellegagi rääkida?
Küsi julgelt abi LasteAbi
Logi sisse
Sulge

"countpairs" - 1 õppematerjal

PPK outdated
24
doc

PPK(outdated)

return str.charAt(0) + "*" + allStar(str.substring(1)); 5. Given a string, compute recursively a new string where identical chars that are adjacent in the original string are separated from each other by a "*". if (str.length()<2) return str; if(str.charAt(0)==str.charAt(1)) return str.charAt(0) + "*" + pairStar(str.substring(1)); return str.charAt(0) + pairStar(str.substring(1)); 10. We'll say that a "pair" in a string is two instances of a char separated by a char. countPairs("axa") → 1 if(str.length() < 3) return 0; if(str.charAt(0)==str.charAt(2)) return 1 + countPairs(str.substring(1)); return countPairs(str.substring(1)); 11. Put certain letter in the end of given string if(str.length()==1 || str.equals("")) return str; if(str.charAt(0)=='x') return endX(str.substring(1)) + "x"; return str.charAt(0) + endX(str.substring(1)); 12. Given a string that contains a single pair of parenthesis,

Informaatika → Java programmeerimine
35 allalaadimist


Sellel veebilehel kasutatakse küpsiseid. Kasutamist jätkates nõustute küpsiste ja veebilehe üldtingimustega Nõustun