Click the Twitter icon to follow our tweets and
know more about us.

Program to write electronic configuration without exceptions till 30

class electronic
{
   public static void main(int z)
   {
       String sb[]={"","1s","2s","2p","3s","3p","4s","3d"};
       int a[]=new int[8];
       int sbsh[]={0,2,2,6,2,6,2,10};
       int n=1, s=1;
       while(z>0)
       {
           a[s]=z<sbsh[s]?z:sbsh[s];
           z=z-a[s];
           s++;
       }
       for(int j=1;j<8;j++)
       {
           if(a[j]!=0)
           System.out.print(sb[j]+"["+a[j]+"]");
       }
   }
}

Comments (0)

Post a Comment