We have performed molecular orbital calculations for SF6 and H2S, using the discretevariational X-alpha method. Energies and cross sections of virtual states are obtained for theoretical spectra of sulfur K, L(II,III) and fluorine K x-ray absorptions for the SF6 molecule. They are in good agreement with the experimental results. Through the same calculation procedures, the theoretical spectra of sulfur K and L(II,III) absorptions for H2S are derived. The obtained molecular orbitals represent the experimental spectra below the ionization energy very well. SF6 has distinct shape resonances above the ionization energy, in contrast to H2S which has pre-edge peaks as a main structure. For the SF6 molecule, shape resonances come from the scattering at the steep change of attractive potential of surrounding fluorine atoms. It is demonstrated that phase shift due to the scattering causes the resonances without a potential barrier. Various spectral differences among the sulfur K, L(II,III) and the fluorine K absorptions in peak width and in base line are related to the character of wave functions. Other resonances among the fluorine wave functions contribute to the characteristics of the base line which was explained as the continuum state alone previously. For the H2S molecule, the reason for the absence of resonances is attributable to the weak scattering power of hydrogen atoms.