Created
August 16, 2016 06:22
-
-
Save sorz/d6a4986222fcc30642d92ac41be9aa29 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 MultiTable { | |
public static void printMulti(int row, int col) { | |
if (row == 0 && col == 0) | |
System.out.printf(" * "); | |
else if (col == 0) | |
System.out.printf("%4d ", row); | |
else if (row == 0) | |
System.out.printf("%4d ", col); | |
else | |
System.out.printf("%4d ", row * col); | |
if (col < 10) | |
System.out.printf("|"); | |
} | |
public static void main(String[] args) { | |
for (int row=0; row<21; row++) { | |
for (int col=0; col<11; col++) { | |
if (row % 2 == 0) { | |
MultiTable.printMulti(row/2, col); | |
} else { | |
System.out.printf("-----"); | |
if (col < 10) | |
System.out.printf("+"); | |
} | |
} | |
System.out.println(""); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment