PHP,161字节
在线尝试
码
function f($m,$n){$t=["table>","th>","td>","tr>","</"];echo strtr("
<0<3".str_repeat("<1A41",$n)."43".str_repeat("<3".str_repeat("
<2A42",$n)."43",$m-1)."40",$t);}
说明
function f($m,$n){
$t=["table>","th>","td>","tr>","</"]; //array representing the tags its created
echo strtr("<0<3".str_repeat("<1A41",$n)."43" //strtr it's called and uses
//the array to replace values
.str_repeat("<3". //repeat the tags
str_repeat("<2A42",$n) //repeat the tags again
."43",$m-1)."40",$t);
//its repeated m-1 times because head is counted as one row
}
PHP,193字节
全表结构忘了<tfooter>
<thead>, <tbody>..etc..
尝试功能示例
function f($m,$n) {$t=["table>","thead>","tbody>","th>","td>","tbody>","tr>"];
echo strtr(
"<0<1".str_repeat("<3A</3",$n).
"</1<2".str_repeat(
"<6".str_repeat("<4A</4",$n)
."</6",$m-1)."</2</0",
$t);
}
说明
$t=["table>","thead>","tbody>","th>","td>","tbody>","tr>"];
与表中的所有标签的数组它的建造,然后用str_repeat
一个号指的数组中的索引写,然后以strtr
该字符串加上数组传递