Java String Manipulation into Columns -


I need to have been working on a tool to split me the text column.

For example - 1 2 3 4 5 6 7 8 9 1

If the duration of 2 - 1,3,5,7,9 and 2,4,6,8 , 1

if duration is 3 - 1,4,7,1 and 2,5,8 and 3,6 9

etc. I am struggling to build this algorithm, any help is appreciated! How about best to build these types of algorithms? I wrote it on paper, but can not be moved to the code! I am stuck on creating another loop to increase the duration. Here is an example that I have done so far

  string to_test = "1234567891"; Stringbilder sb = new stringbiller (); Int duration = 2; Int startAt = 0; Int verbatim check = 0; While (startAt & lt; span) {for (int i = 0; i & lt; to_test.length (); i ++) {if (i% period == 0) {sb.append (to_test.charAt (characterToCheck )); } CharacterToCheck ++; } // string has been created system.out.println (sb); Sb = new stringbilder (); StartAt ++; CharacterToCheck = startAt; }}  

Try it out.

  import java .itil.Arrays; Public category tester 1 {public static zero main (string [] args) {string to_test = "1234567891"; Stringbirder sb = new string builder (""); Four [] charArray = to_test.toCharArray (); Int Period = 3; For (Int J = 0; J & lt; span; j ++) to {(Int i = j; i & lt; Charare. Lang; i + = period) {Sbkappend (Charare [i]) ; } Sb.append (";"); } System.out.println (sb); }}  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -