All pastes #384574 Raw Edit

ioana

public text v1 · immutable
·published 2007-03-07 04:56 UTC
rendered paste body
    public static String makePalindrome(String s)
    // pre: s is not null
    // post: creates and returns the String s concatenated with
    // the reverse of s
    {   if (s.length() == 1){
         String b = s + s;
          return b;
        }else{
        
        //if (s.length() > 1) { 
          String b = "";
          for (int i = s.length(); i > 0; i --) {
          String c = A06Q3.makePalindrome(s.substring(i,i));
            if (i < s.length()) {
              int mid = b.length()/2;
              b = b.substring(1,mid) + c + b.substring(mid + 1, s.length());
            }//if
          }//for
        return b;
        }//if
    }