Skip to main content
2 of 7
added 73 characters in body
Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36

PHP, 306 Bytes

for($p=str_pad;$i++<$a=$argn;)$r[$i==$a||!($i%2)][]=sprintf("%02d",$i);echo strtr("01112344453",($a>1?[$p("+",$c=($a/2^0)*5+1,"----+")."\n",$p("|",$c,"    |")."\n","| ".join(" | ",$r[0])." |\n"]:["","",""])+[3=>$p("+",$c=ceil($a/2)*5+1,"----+")."\n",$p("|",$c,"    |")."\n","| ".join(" | ",$r[1])." |\n"]);

replace ["","",""] with ["\n","\n","\n"] if you want newlines for case 1

Try it online!

Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36