循环

99 阅读1分钟

当循环不确定次数时,使用while循环,确定循环次数建议使用for循环

  • while循环

image.png

  • for循环

image.png

breakcontinue的区别:

  • break跳出循环,不再执行之后的操作
  • continue仅跳出当前循环,继续执行之后的循环