Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. public static String generarnuevacadena(String str, int index){ //debe llegarle str.length -1
  2. String nstr="";
  3. if (index==-1)
  4. {
  5. for (int i=0;i<str.length()+1;i++)
  6. {
  7.  
  8. nstr+=alfabeto.charAt(0);
  9. }
  10. }
  11. else
  12. {
  13. if(str.charAt(index)==alfabeto.charAt(alfabeto.length()-1))
  14. {
  15. for(int i=0;i<str.length();i++)
  16. {
  17. if (i==index)
  18. {
  19. nstr=nstr+"A";
  20. }
  21. else
  22. {
  23. nstr=nstr+str.charAt(i);
  24. }
  25. }
  26. nstr=generarnuevacadena(nstr,index-1);
  27.  
  28. }
  29. else
  30. {
  31. for(int i=0;i<str.length();i++)
  32. {
  33. if (i==index)
  34. {
  35. nstr=nstr+ alfabeto.charAt(alfabeto.indexOf(str.charAt(index),0)+1);
  36. }
  37. else
  38. {
  39. nstr=nstr+str.charAt(i);
  40. }
  41. }
  42.  
  43. }
  44. }
  45. return nstr;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement