Page 578 - Computer science 868 Class 12
P. 578

46       while(count<=n)
                47       {

                48       nh=0;
                49       for(i=0;i<n;i++)
                50       {

                51       if(ar[i]>nh && ar[i]<h)  // finding second highest

                52       {
                53       nh=ar[i];
                54       nhp=i;

                55          }
                56       }

                57       if(count%2==0)
                58       {

                59       temp=ar[right];
                60       ar[right]=ar[nhp];

                61       ar[nhp]=temp;
                62       right++;

                63       }
                64       else

                65       {
                66       temp=ar[left];

                67       ar[left]=ar[nhp];
                68       ar[nhp]=temp;

                69       left--;
                70       }

                71       h=nh;
                72       count++;

                73          }
                74       }
                75       void display()

                76       {

                77       for(int i=0;i<n;i++)
                78       {







                576576  Touchpad Computer Science-XII
   573   574   575   576   577   578   579   580   581   582   583