Nondiffracting optical beams play an important role in contemporary optics due to their special propagation characteristics, i.e., nondiffracting in a diffraction-free zone, shape recovering behind obstacles or self-healing property. Liquid crystal spatial light modulators (LC-SLM) are widely used for generating nondiffracting optical beams in virtue of programmable and dynamic features. In this paper, we propose a complex amplitude modulation technique that can encode any scalar complex fields for generating the complex nondiffracting beams. Before experiment, the phase modulation curve of the phase-only LC-SLM is optimized into being linear in a range of 0-2πby gamma correction in the way of variable binary phase gratings. Then, we experimentally generate the nonaccelerating beams, e.g., two zero-order Bessel beams with variable intensity distributions, and the nondiffracting petal-like beams generated by interfering with two coaxial Bessel beams. By scanning a reflection mirror near the focal region along the optical axis, a stack of two-dimensional images is acquired, and then a three-dimensional intensity profile of the beam is reconstructed with a software. We also experimentally demonstrate a new kind of multi-main-lobe accelerating beam with parabolic accelerating trajectory by modifying the spatial spectrum of classical Airy beam. Compared with the so-called vectorial accelerating beam with multiple main lobes in spheroidal coordinates, our generated two-main-lobe accelerating beam has a very high energy efficiency. The self-healing property of the two-main-lobe accelerating beam is also demonstrated. The presented technique can generate a variety of complex nondiffracting optical beams rapidly and obtain their three-dimensional intensity distributions accurately, which has potential applications in the fields of optical microscope, optical date storage, optical trapping, optical micromachining, etc.