18. As shown in Figure 2, in a $5 \times 5$ grid, the numbers in each row and each column form an arithmetic sequence. Then the value of $x$ is ( ).
(A) 21
(B) 31
(C) 36
(D) 40
(E) 42
18. B.

Let the element in the $i$-th row and $j$-th column be $a_{ij} (i, j=1,2, \cdots, 5)$.
By the properties of arithmetic sequences and the given conditions, we have
$$
\begin{array}{l}
x=a_{33}=\frac{a_{13}+a_{53}}{2} \\
=\frac{\frac{1}{2}\left(a_{11}+a_{15}\right)+\frac{1}{2}\left(a_{51}+a_{55}\right)}{2}=31 .
\end{array}
$$