7. Five students $A, B, C, D$ and $E$ form a team to take part in a 5-leg relay competition. If $\dot{A}$ cannot run the first leg and $D$ cannot run the last leg, how many ways can we arrange them to run the relay?
(A) 74
(B) 76
(C) 78
(D) 80
(E) 82
7. Ans: $\mathrm{C}$
Total number of ways is
$$
5!-4!-4!+3!=120-24-24+6=78 \text {. }
$$

Alternatively, we consider the following cases:
Case (i): $A$ and $D$ do not run the first or last leg. In this case, the number of arrangements is $3 \times 2 \times 3!=36$.

Case (ii): $D$ runs the first leg. In this case, number of arrangements is $4!=24$.
Case (iii): $D$ does not run the first leg and $A$ runs the last leg. In this case, number of ways is $3 \times 3!=18$.

Therefore, total number of ways $=36+24+18=78$.