esdras Posted October 23, 2003 Report Share Posted October 23, 2003 eu preciso tratar algumas strings... tipo: onde aparece caracteres repetidos (Ex.: "AA") deicar o resultado (ex.: "A") Quote Link to comment Share on other sites More sharing options...
0 iSoron Posted October 26, 2003 Report Share Posted October 26, 2003 Faz assim:1. Transforma pra char[]. Faz isso com o metodo toCharArray()2. Cria um char[] paralelo pra ir guardando o resultado.3. Usa um algoritmo parecido com esse:private char[] entrada; private char[] saida; private int j=1,i; saida[0] = entrada[0]; for(i=1;i<saida.length;i++) { if(entrada[i] != saida[j-1]) { saida[j++] = entrada[i]; } }4. Transforma de volta pra string.Acho q é só..falou! Quote Link to comment Share on other sites More sharing options...
Question
esdras
eu preciso tratar algumas strings... tipo: onde aparece caracteres repetidos (Ex.: "AA") deicar o resultado (ex.: "A")
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.