timetable.java
来自「tutorial solutions for java programing」· Java 代码 · 共 45 行
JAVA
45 行
// Exercise 3.8
public class TimeTable { //saved as "TimeTable.java"
public static void main (String[] args) {
//display the number title
System.out.print(" * |");
for(int TitleCol = 1; TitleCol <= 9; TitleCol++){
System.out.printf("%3d", TitleCol);
}
System.out.println();
System.out.println("-------------------------------");
//print the table body
for(int row = 1; row <= 9; row++){
System.out.printf("%2d |", row);
//display the products and align properly
for(int col = 1; col <= 9; col++){
System.out.printf("%3d", row*col);
}
System.out.println();
}
//time table from 1 to 12
//display the number title
/*System.out.print(" * |");
for(int TitleCol = 1; TitleCol <= 12; TitleCol++){
System.out.printf("%4d", TitleCol);
}
System.out.println();
System.out.println("-----------------------------------------------------");
//print the table body
for(int row = 1; row <= 12; row++){
System.out.printf("%3d |", row);
//display the products and align properly
for(int col = 1; col <= 12; col++){
System.out.printf("%4d", row*col);
}
System.out.println();
}*/
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?