During the formation of cations, electrons are lost while in the formation of anions, electrons are added to the valence shell. The number of electrons added or lost is equal to the numerical value of the charge present on the ion. Following this general concept, we can write the electronic configuration of all the ions given in the question