2020-10-06 23:10:08 +05:30

1.7 KiB
Raw Blame History

id, challengeType, videoUrl, title
id challengeType videoUrl title
5a23c84252665b21eecc7eb1 5 身份矩阵

Description

单位矩阵是大小为\n \次n \)的方阵,其中对角元素都是1 s1所有其他元素都是0 s。 \ begin {bmatrix} 100 \ cr 010 \ cr 001 \ cr \ end {bmatrix}编写一个以数字'n'作为参数并返回单位矩阵的函数订单nx n。

Instructions

Tests

tests:
  - text: <code>idMatrix</code>应该是一个功能。
    testString: assert(typeof idMatrix=='function');
  - text: <code>idMatrix(1)</code>应该返回一个数组。
    testString: assert(Array.isArray(idMatrix(1)));
  - text: '<code>idMatrix(1)</code>应返回<code>&quot;+JSON.stringify(results[0])+&quot;</code> 。'
    testString: assert.deepEqual(idMatrix(1),results[0]);
  - text: '<code>idMatrix(2)</code>应返回<code>&quot;+JSON.stringify(results[1])+&quot;</code> 。'
    testString: assert.deepEqual(idMatrix(2),results[1]);
  - text: '<code>idMatrix(3)</code>应返回<code>&quot;+JSON.stringify(results[2])+&quot;</code> 。'
    testString: assert.deepEqual(idMatrix(3),results[2]);
  - text: '<code>idMatrix(4)</code>应返回<code>&quot;+JSON.stringify(results[3])+&quot;</code> 。'
    testString: assert.deepEqual(idMatrix(4),results[3]);

Challenge Seed

function idMatrix (n) {
  // Good luck!
}

After Test

console.info('after the test');

Solution

// solution required

/section>