Discuss / Java / 冒泡降序

冒泡降序

Topic source

逆风_13924

#1 Created at ... [Delete] [Delete and Lock User]

    for(int i=0;i<ns.length-1;i++)

        {

           for(int j=0;j<ns.length-1-i;j++)

             {

                 if(ns[j]<ns[j+1])

                     {

                        int temp=ns[j];

                        ns[j]=ns[j+1];

                        ns[j+1]=temp;

                     }

             }

        }


  • 1

Reply