数字楼梯-嵌套循环

时间:2019-04-12 17:38:17

标签: javascript

我正在尝试

this

仅使用嵌套循环和if语句。

for (let i = 0; i < 10; i++) {
  for (let j = 0; j < 10; j++) {
    if (j < i) {
      document.write(j + " ");
    }
  }
  document.write("<br>");
}

但是,输出与我想要的不同(尝试运行代码段)。

2 个答案:

答案 0 :(得分:2)

您必须使用from django.db import models class CHRecord(models.Model): namespace = models.CharField(max_length=32) filepath = models.FileField() # Not sure what this represents in your question, but if you use # PostgreSQL as your backend, might want an Array sel_sets = models.CharField(max_length=512) # Saves a row to a database (local SQLite by default) CHRecord.objects.create(namespace="John:", filepath="C:/temp/", sel_sets="xyz") # Get matching rows translating to a SQL query CHRecord.objects.filter(namespace__contains="John") 的值来计算要打印的数字

tasks:
  - include_role:
      name: repos.linux
      apply:
        tags:
          - install
          - check

答案 1 :(得分:2)

这样,您将不需要IF语句:

for (var i = 0; i < 10; i++) {
    for (var j = 0; j <= i; j++) {
        document.write(j * i, ' ')
    }
    document.write('<br>')
}