Four, (Full marks 20 points) In $\triangle A B C$, if $\frac{\cos A}{\sin B}+$ $\frac{\cos B}{\sin A}=2$, and the perimeter of $\triangle A B C$ is 12. Find the maximum possible value of its area.
$$
\begin{array}{l}
\text { From the given, } \\
\sin A \cdot \cos A+\sin B \cdot \cos B=2 \sin A \cdot \sin B, \\
\text { i.e., } \sin A(\cos A-\sin B)+\sin B(\cos B-\sin A) \\
=0 \text {. } \\
\sin A\left[\sin \left(90^{\circ}-A\right)-\sin B\right] \\
+\sin B\left[\sin \left(90^{\circ}-B\right)-\sin A\right] \\
=2 \sin \frac{90^{\circ}-A-B}{2}\left[\sin A \cdot \cos \left(45^{\circ}-\frac{A-B}{2}\right)\right. \\
\left.+\sin B \cdot \cos \left(45^{\circ}+\frac{A-B}{2}\right)\right) \\
=2 \sin \frac{90^{\circ}-A-B}{2} \times \frac{\sqrt{2}}{2} \times\left(\cos \frac{A-B}{2} \cdot(\sin A\right. \\
\left.+\sin B)+\sin \frac{A-B}{2} \cdot(\sin A-\sin B)\right) \\
\end{array}
$$
$$
=0 \text {. }
$$
$$
\begin{array}{l} 
\text { Also, } \cos \frac{A-B}{2} \cdot(\sin A+\sin B) \\
+ \sin \frac{A-B}{2} \cdot(\sin A-\sin B) \\
= 2 \cos ^{2} \frac{A-B}{2} \sin \frac{A+B}{2}+2 \cos \frac{A+B}{2} \\
\quad \cdot \sin ^{2} \frac{A-B}{2}>0,
\end{array}
$$

Therefore, $\sin \frac{90^{\circ}-A-B}{2}=0$.
Then $90^{\circ}-\angle A-\angle B=0, \angle A+\angle B=90^{\circ}$, which means $\triangle A B C$ is a right triangle.

Let the sides opposite to $A, B, C$ be $a, b, c$ respectively. According to the problem,
$$
\begin{array}{l}
a+b+\sqrt{a^{2}+b^{2}}=12 . \\
\because a+b \geqslant 2 \sqrt{a b}, a^{2}+b^{2} \geqslant 2 a b, \\
\therefore 12=a+b+\sqrt{a^{2}+b^{2}} \geqslant 2 \sqrt{a b}+\sqrt{2 a b},
\end{array}
$$

Thus, $a b \leqslant 36(2-\sqrt{2})^{2}$.
Then $S=\frac{1}{2} a b \leqslant 18(2-\sqrt{2})^{2}=36(3-2 \sqrt{2})$,

Therefore, $S_{\max }=36(3-2 \sqrt{2})$.