Skip to content

Instantly share code, notes, and snippets.

@TheLouisHong
Last active December 25, 2015 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheLouisHong/7046373 to your computer and use it in GitHub Desktop.
Save TheLouisHong/7046373 to your computer and use it in GitHub Desktop.
Another one of martins assignments. 1.03 version
public class PrintNumberTriangle{
public static void main(String []args){
int midNumber = 8;
for (int y = 1; y<=midNumber; y++) {
for (int x = 1; x<=y; x++) {
System.out.print(x + " ");
}
for (int space = 0; space<4*(midNumber-y)-2; space++) {
System.out.print(" ");
}
for (int x = y; x>=1; x--) {
if (x!=midNumber )
System.out.print(x + " ");
}
System.out.println();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment