The distribution of X-ray sources in our galaxy is obtained, assuming that the absolute X-ray luminosities of these sources are the same. The distribution is found to be in good correlation with the distribution of interstellar gas. The density of X-ray sources is nearly proportional to the square density of gas. This indicates that X-ray sources are comparatively young. The relation between the densities of X-ray sources and gas allows us to estimate the X-ray intensities of various objects such as Magellanic Clouds and Andromeda nebula, and also to obtain the average X-ray luminosity of spiral galaxies. The latter should increase as the age of a galaxy decreases, since the amount of gas decreases as the galaxy evolves. Under the assumptions that the gas density is inversely proportional to the age and that galaxies older thant 0/30 are visible in X-rays, wheret 0 is the present age of the universe, the contribution of X-ray sources in distant galaxies to the background component is calculated. The intensity and the spectrum of the background component of X-rays thus obtained are in fair agreement with observed ones in the energy range between 1 and 4 keV but significantly deviate from the latter at high energies.