程式碼如下:
public class Test_9x9 {
public static void main(String[ ] args) {
for (int i = 1; i <=9; i++) {
for (int j = 1; j <=i; j++) {
System.out.print(j+"*"+i+"="+(i*j)+"\t");
}
System.out.println();
擴充套件資料:
其他語言列印九九乘法表的程式碼:
1、C語言
#include <stdio.h>
int main(){
int i,j,n;
for(i=1;i<=9;i++){
for(j=1;j<=i;j++)
printf("%d*%d=%2d ",i,j,i*j);
printf("\n");
return 0;
2、python
for i in range(1, 10):
for j in range(1, i+1):
print("{}x{}={}\t".format(j, i, i*j), end="")
print()
程式碼如下:
public class Test_9x9 {
public static void main(String[ ] args) {
for (int i = 1; i <=9; i++) {
for (int j = 1; j <=i; j++) {
System.out.print(j+"*"+i+"="+(i*j)+"\t");
}
System.out.println();
}
}
擴充套件資料:
其他語言列印九九乘法表的程式碼:
1、C語言
#include <stdio.h>
int main(){
int i,j,n;
for(i=1;i<=9;i++){
for(j=1;j<=i;j++)
printf("%d*%d=%2d ",i,j,i*j);
printf("\n");
}
return 0;
}
2、python
for i in range(1, 10):
for j in range(1, i+1):
print("{}x{}={}\t".format(j, i, i*j), end="")
print()