在控制台上打印以下图案的 Java 程序

2025 年 3 月 17 日 | 阅读 1 分钟
Java program to print the following pattern on the console

算法

  • 步骤 1: 开始
  • 步骤 2: 设置 i = 1。重复步骤 3 至 7,直到 i <= 10。
  • 步骤 3: 设置 j = 1。重复步骤 4 和 5,直到 j <= 10。
  • 步骤 4: if(i==0 or i==10 or j==0 or j==10) then PRINT 1 else PRINT ""
  • 步骤 5: 设置 j = j + 1
  • 步骤 6: PRINT 新的一行。
  • 步骤 7: 设置 i = i + 1
  • 步骤8: 结束

程序

输出

Java program to print the following pattern on the console
下一个主题Java 程序