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

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© mandoooo 中级黑马   /  2015-10-10 00:50  /  472 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. /*
  2. one

  3. *****
  4. ****
  5. ***
  6. **
  7. *


  8. two

  9. *
  10. **
  11. ***
  12. ****
  13. *****


  14. three

  15. ----*
  16. ---* *
  17. --* * *
  18. -* * * *
  19. * * * * *


  20. four

  21. 1*1=1
  22. 2*1=2 2*2=4
  23. 3*1=3 3*2=6 3*3=9


  24. */
  25. class  XingXing
  26. {
  27.         public static void main(String[] args)
  28.         {
  29.                 one();
  30.                 System.out.println();
  31.                 two();
  32.                 System.out.println();
  33.                 three();
  34.                 System.out.println();
  35.                 four();

  36.         }
  37.         public static void one()
  38.         {
  39.                 for(int x=0;x<5;x++)
  40.                 {
  41.                         for(int y=0;y<5-x;y++)
  42.                         {
  43.                         System.out.print("*");
  44.                         }
  45.                         System.out.println();
  46.                 }
  47.         }
  48.         public static void two()
  49.         {
  50.                 for(int x=0;x<5;x++)
  51.                 {
  52.                         for(int y=0;y<=x;y++)
  53.                         {
  54.                         System.out.print("*");
  55.                         }
  56.                         System.out.println();
  57.                 }
  58.         }
  59.         public static void three(){
  60.                
  61.                 for(int x=0;x<5;x++)
  62.                 {
  63.                         for(int y=0;y<4-x;y++)
  64.                         {
  65.                                 System.out.print("-");
  66.                         }
  67.                         for(int z=0;z<=x;z++)
  68.                         {
  69.                                 System.out.print("*"+" ");
  70.                         }
  71.                         System.out.println();
  72.                 }
  73.         }
  74.         public static void four(){
  75.                 for(int x=1;x<=9;x++)
  76.                 {
  77.                         for(int y=1;y<=x;y++)
  78.                         {
  79.                                 System.out.print(x+"*"+y+"="+x*y+"\t");
  80.                         }
  81.                         System.out.println();
  82.                 }

  83.         }
  84. }
复制代码


这是毕老师视频里的练习题哦~

1 个回复

倒序浏览
基础练习   夯实这些基础的语法就行了
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马