We carry out a comparison between observations and hydrodynamic simulations of entropy profiles of groups and clusters of galaxies. We use the Tree+SPH GADGET code to simulate four halos of sizes in the M500=1.0-16*E13 h-1 Msun range, corresponding to poor groups up to Virgo-like clusters. We concentrate on the effect of introducing radiative cooling, star formation, and a variety of non-gravitational heating schemes on the entropy structure and the stellar fraction. We show that all the simulations result in a correct entropy profile for the Virgo-like cluster. With the heating energy budget of ~ 0.7 keV/particle injected at zh=3, we are also able to reproduce the entropy profiles of groups. We obtain the flat entropy cores as a combined effect of preheating and cooling, while we achieve the high entropy at outskirts by preheating. The resulting baryon fraction locked into stars is in the 25-30% range, compared to 35-40% in the case of no preheating. Heating at higher redshift, zh=9, strongly delays the star-formation, but fails to produce a sufficiently high specific entropy.