給定行數(shù)和列數(shù),寫3個函數(shù)分別輸出如下的二維數(shù)組(假設(shè)給的行數(shù)是5,列數(shù)是4):1 2 3 45 6 7 8?9 10 11 1213 14 15 1617 18 19 20?1 6 11 16?2 7 12 173 8 13 184 9 14 195 10 15 201 10 11 20?2 9 12 193 8 13 184 7 14 175 6 15 16這個怎么做啊??(function(window,?document)?{
let?sorts?=?function(option)?{
????this._init(option);
};
sorts.prototype._init?=?function(option)?{
this.arrs?=?option.arr;
this.rows?=?option.rows;
this.cols?=?option.cols;
this._create();
};
sorts.prototype._create?=?function(option)?{
let?nums?=?0;
for?(let?i?=?0;?i?<?this.rows;?i++)?{
document.write('<br>');
for?(let?j?=?0;?j?<?this.cols;?j++)?{
if?(this.arrs[nums])?{
document.writeln(this.arrs[nums]);
nums++;
}
}
}
};
window.sorts?=?sorts
})(window,?document);
new?sorts({
????rows:?5,
????cols:?4,
????arr:?['1',?'2',?'3',?'4',?'5',?'6',?'7',?'8',?'9',?'10',?'11',?'12',?'13',?'14',?'15',?'16',?'17',?'18',?'19',?'20']
});?這個類型不能算。
關(guān)于前端面試題
叢從綠草
2019-01-22 14:27:13