我想画一个网格,并将皇后放置在每行选定的列中。我可以画网格,但皇后的放置位置不正确。
\makeatletter\newcommand{\showQL}[3][,]{%
\def\row{#2}\def\negOne{-1}
\def\dolist##1{\expandafter\@dolist##1#1\@eol}%
\def\@dolist##1#1##2#1##3\@eol{%
\ifx\negOne##2\else\draw node at ($(##1,##2)+(45:.75)$) {\symqueen};\fi
\ifx\@eol##3\@eol\else\@dolist##2+1#1##3\@eol\fi}%
\dolist{#2,#3}%
}\makeatother
\begin{tikzpicture}
\def\xMin{0}\def\xMax{5}\def\yMin{0}\def\yMax{5}
\foreach\i in {\xMin,...,\xMax}{\draw[very thin,gray] (\i,\yMin)--(\i,\yMax);}
\foreach\i in {\yMin,...,\yMax}{\draw[very thin,gray] (\xMin,\i)--(\xMax,\i);}
\showQL{5}{-1,3,2,1,4,5}
\end{tikzpicture}