Created
April 15, 2017 20:17
-
-
Save muthugit/644592334ad133ac7bbd2aa654f3d2c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Triangle { | |
public static void main(String[] args) { | |
String input = "abcdefghijklmnopqrstuvwxyz"; | |
int rowSize = 1, stringPosition = 0; | |
for (int index = 0; index < (input.toCharArray().length / 2); index++) { | |
String output = ""; | |
for (int i = 0; i < rowSize; i++) { | |
output = output + (input.toCharArray()[stringPosition]); | |
stringPosition++; | |
} | |
System.out.println(output); | |
if (stringPosition >= input.toCharArray().length / 2) | |
rowSize--; | |
else | |
rowSize++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment