6. Given the function
$$
y=\left\{\begin{array}{ll}
x^{2}-2 x, & x \leqslant 3 ; \\
x^{2}-10 x+24, & x>3,
\end{array}\right.
$$

and the equation $y=k$ has exactly three solutions for $x$. Then the value of $k$ is ( ).
(A) 3
(B) 2
(C) 1
(D) 0
6. A.

As shown in Figure 9.
From the graph, it is easy to see that the line $y=3$ intersects the function graph at exactly three points, i.e., when $k=3$, the $x$ values that satisfy $y=k$ are exactly three.