The ability to implement quantum operations plays a fundamental role in manipulating quantum systems. Creation and annihilation operators which transform one quantum state into another by adding or subtracting a particle are crucial in constructing the quantum description of many-body quantum theory and quantum field theory. Here we present a quantum algorithm to perform the creation and annihilation operators by the linear combination of unitary operations associated with a two-qubit ancillary system. Our method can realize shift operators akin to creation and annihilation operators simultaneously in the subspace of the whole system. A prototypical experiment was performed with a four-qubit liquid-state nuclear magnetic resonance processor, demonstrating the algorithm via full-state tomography. With a postselected probability of about 50%, the shift operators are realized with a fidelity above 96%. Moreover, our method can be employed to quantum random walk in an arbitrary initial state. With the prosperous development of quantum computing, our work provides a quantum control technology to implement nonunitary evolution in a near-term quantum computer.