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文字列の配列に加えて渡されます