12. Given line segments of lengths $1,2, \cdots, n-1$, one of each, select two different segments to form a triangle with a segment of length $n$. How many different ways are there to do this?
12. Solution 1 When the selected side length is $k$, the other side length must be $>n-k$,

i.e., $n-k+1, n-k+2, \cdots, n-1$ has $k-1$ ways to choose.
Therefore, the number of ways to form a triangle (including repeated counts) is
$$
\sum_{k=1}^{-1}(k-1)=\frac{1}{2}(n-1)(n-2) \text {. }
$$

However, among the selected two segments being equal, they do not meet the condition and should be removed.
Moreover, each qualified triangle is counted twice.
When $n$ is even, the two selected side lengths may both be $\frac{n}{2}+1, \frac{n}{2}+2, \cdots, n-1$,
there are $(n-1)-\frac{n}{2}=\frac{n}{2}-1=\frac{1}{2}(n-2)$ ways,
Thus, when $n$ is even, the number of qualified selections is
$\frac{1}{2}\left[\frac{1}{2}(n-1)(n-2)-\frac{1}{2}(n-2)\right]=\frac{1}{4}(n-2)^{2}$ ways;
When $n$ is odd, the two selected side lengths may both be
$\frac{n+1}{2}, \frac{n+1}{2}+1, \cdots, n-1$, there are $(n-1)-\left(\frac{n+1}{2}-1\right)=\frac{n-1}{2}$ ways.
Thus, when $n$ is odd, the number of qualified selections is
$$
\frac{1}{2}\left[\frac{1}{2}(n-1)(n-2)-\frac{1}{2}(n-1)\right]=\frac{1}{4}(n-1)(n-3) \text { ways. }
$$

Solution 2 Let the selected segments be $a, b$, without loss of generality, assume $1 \leqslant a < b \leqslant n$, if the $a$ segment is fixed, then the $b$ side can only take segments of length $l \geqslant n-a+1$.
By $n-a+1 \leqslant n-1$, then $a \geqslant 2, a \leqslant n-2$,
When $a=2$, $b \geqslant n-2+1=n-1$, there are 10 ways to choose,
When $a=3$, $b \geqslant n-3+1=n-2$, there are 2 ways to choose,
When $a=4$, $b \geqslant n-4+1=n-3$, there are 3 ways to choose.
When $a=\left[\frac{n-1}{2}\right]$, 
$$
\left\{\begin{array}{l}\text { If } n \text { is odd, } b \geqslant n-\left[\frac{n+1}{2}\right]+1=\frac{n+1}{2}, \text { there are } \frac{n-1}{2}-1 \text { ways to choose. } \\ \text { If } n \text { is even, } b \geqslant n-\left[\frac{n-1}{2}\right]+1=\frac{n}{2}, \text { there are } \frac{n-2}{2} \text { ways to choose. }\end{array}\right.
$$
When $a>\left[\frac{n-1}{2}\right]$, only $b>a$ is required.

When $a=n-3$, $b \geqslant n-2$, there are 2 ways to choose,
When $n=n-2$, $b \geqslant n-1$, there is 1 way to choose.
When $n$ is odd, there are $2\left[1+2+\cdots+\frac{n-3}{2}\right]=\frac{(n-1)(n-3)}{4}$ ways to choose.
When $n$ is even, there are $2\left[1+2+\cdots+\frac{n-4}{2}\right]+\frac{n-2}{2}=\frac{(n-2)^{2}}{4}$ ways to choose.