  We predict how the C, N, and O abundances within the interstellar medium of
galaxies evolve as functions of the galaxy star formation history (SFH). We
adopt a hydrodynamical cosmological simulation, focusing on three star-forming
disc galaxies with different SFHs. By assuming failed supernovae, we can
predict an increasing trend of the gas-phase N/O--O/H abundance diagram, which
was not produced in our previous simulations without failed supernovae. At high
redshifts, contrary to the predictions of classical chemical evolution models
with instantaneous mixing approximation, we find almost flat trends in the
N/O--O/H diagram, which are due to the contribution of intermediate-mass stars
together with an inhomogeneous chemical enrichment. Finally, we also predict
that the average N/O and C/O steadily increase as functions of time, while the
average C/N decreases, due to the mass and metallicity dependence of the yields
of asymptotic giant branch stars; such variations are more marked during more
intense star formation episodes. Our predictions on the CNO abundance evolution
can be used to study the SFH of disc galaxies with the James Webb Space
Telescope.
