列印九九乘法表

2021-07-25 13:44:59 字數 560 閱讀 6106

問題描述:列印九九乘法表

解決方法:使用兩重迴圈,一重迴圈,或者遞迴都可以解決

**示例:

package cn.ccnu.demo1;

public class demo3

system.out.println();

} }//使用一重迴圈列印九九乘法表

public static void gettableonefor()

} }//不使用迴圈,使用遞迴列印九九乘法表

/* * 使用遞迴列印九九乘法表的演算法:

* 1,根據分析可以得知,九九乘法表的第n行有n個小式子

* 2,第n-1行比第n行少乙個式子

* 3,第1行只要乙個式子(遞迴的結束條件)

*/public static void gettablenofor(int num)else

} private static void print(int i, int num) }

public static void main(string args)

}

列印九九乘法表

public static void main string args system.out.println for i in range 1 10 print f x1 for i in range 1 10 for j in range 1 i 1 print f x end end不換行,空格...

python列印九九乘法表

一共有幾行?九行列有什麼規律 第一行,會有一列 第二行,會有二列 第五行,會有五列 第n行,會有n列 code def print row 列印九行 row 1 while row 9 print 當前是第 row,行 row row 1print row 注意 列是動態的 def print co...

Python列印九九乘法表

最近在學習python的時候看到這樣一道題 拿到這道題,首先觀察一下,九行九列的階梯狀,很快想到了用兩層while迴圈巢狀來寫,外層迴圈控制行號 即寫到了第幾行 內層迴圈則控制每一行寫的內容。程式如下 i 1while i 9 j 1while j i print f end t j 1print ...