C++优化遍历

void maoPao(int a[],int len)

{

    for (int i=0; i<len-1; i++) 

   {

        bool yes=true;

        for (int j=0; j<len-i-1; j++) 

      {

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

            {

                int t=a[j];

                a[j]=a[j+1];

                a[j+1]=t;

                yes=false;

            }

        }

        if (yes)

        {

            break;

        }

    }

}

猜你喜欢

转载自blog.csdn.net/qq_41939248/article/details/80401029