Finite-lattice approach to the O(2) and O(3) models in 1+1 dimensions and the (2+1)-dimensional Ising model