A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

  1. /*
  2. 需求:在控制台输如下的形状
  3. *
  4. **
  5. ***
  6. ****
  7. *****

  8. */
  9. class FunctionDemo {
  10. public static void main(String[] args) {
  11. for (int x =0;x <5;x++) {
  12. for (int y=0;y<=x;y++) {
  13. System.out.print("*");
  14. }
  15. System.out.println();
  16. }
  17. //由以上三角形打印九九乘法表
  18. for (int x =1;x <= 9;x++) {
  19. for (int y =1;y<=x;y++) {
  20. System.out.print(y+"*"+x+"="+y*x+"\t");
  21. }
  22. System.out.println();
  23. }

  24. }

  25. }
复制代码

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马