7. Given $A, B$ are digits in the set $\{0,1, \cdots, 9\}$, $r$ is a two-digit integer $\overline{A B}$, $s$ is a two-digit integer $\overline{B A}$, $r, s \in\{00,01$, $\cdots, 99\}$. When $|r-s|=k^{2}$ ( $k$ is an integer), the number of ordered pairs $(A, B)$ is $\qquad$.
7. 42 .

Notice,
$$
|(10 A+B)-(10 B+A)|=9|A-B|=k^{2} \text {. }
$$

Then $|A-B|$ is a perfect square.
When $|A-B|=0$, there are 10 integer pairs:
$$
(A, B)=(0,0),(1,1), \cdots,(9,9) \text {; }
$$

When $|A-B|=1$, there are 18 integer pairs:
$$
(A, B)=(0,1),(1,2), \cdots,(8,9) \text {, }
$$

and their reverse numbers;
When $|A-B|=4$, there are 12 integer pairs:
$$
(A, B)=(0,4),(1,5), \cdots,(5,9) \text {, }
$$

and their reverse numbers;
When $|A-B|=9$, there are 2 integer pairs:
$$
(A, B)=(0,9) \text {, }
$$

and its reverse number.
Thus, the number of ordered pairs that satisfy the condition is
$$
10+18+12+2=42 \text {. }
$$