Based on a splitting method and a composition method, we construct some structure-preserving algorithms with first-order, second-order and fourth-order accuracy for a Lorenz system. By using the Liouville's formula, it is proven that the structure-preserving algorithms exactly preserve the volume of infinitesimal cube for the Lorenz system. Numerical experimental results illustrate that for the conservative Lorenz system, the qualitative behaviour of the trajectories described by the classical explicit fourth-order Runge-Kutta (RK4) method and the fifth-order Runge-Kutta-Fehlberg (RKF45) method is wrong, while the qualitative behaviour derived from the structure-preserving algorithms with different orders of accuracy is correct. Moreover, for the small dissipative Lorenz system, the norm errors of the structure-preserving algorithms in phase space are less than those of the Runge-Kutta methods.