Spectral conditions for the existence of specified paths and cycles in graphs