fork(1) download
  1. class M{
  2. static String c(String s, char c){
  3. String r = "";
  4. int x = 0,
  5. i;
  6. for(String a : s.split("\\|")){
  7. for(i = 0; i++ < x; r += " ");
  8. r += a;
  9. x += a.length();
  10. for(i = -1; i++ < s.replace("|", "").length() - x; r += " ");
  11. r += c + "\n";
  12. }
  13. return r;
  14. }
  15.  
  16. public static void main(String[] a){
  17. System.out.println(c("a|bc|d|e|fgh|ij|k|l|mn|op", '#'));
  18. System.out.println(c("Hello|World", '/'));
  19. System.out.println(c("a|b|c|d|e|f|g", ','));
  20. System.out.println(c("abcdefg", ':'));
  21. System.out.println(c("4|8|15|16|23|42", '%'));
  22. System.out.println(c("E|ac|h s|ecti|on is| one c|haracte|r longer| than the| last!", '!'));
  23. System.out.println(c("This|Code|has||empty||sections", '@'));
  24. }
  25. }
Success #stdin #stdout 0.07s 711680KB
stdin
Standard input is empty
stdout
a                #
 bc              #
   d             #
    e            #
     fgh         #
        ij       #
          k      #
           l     #
            mn   #
              op #

Hello      /
     World /

a       ,
 b      ,
  c     ,
   d    ,
    e   ,
     f  ,
      g ,

abcdefg :

4          %
 8         %
  15       %
    16     %
      23   %
        42 %

E                                                   !
 ac                                                 !
   h s                                              !
      ecti                                          !
          on is                                     !
                one c                               !
                     haracte                        !
                            r longer                !
                                     than the       !
                                              last! !

This                     @
    Code                 @
        has              @
                         @
           empty         @
                         @
                sections @