link* mid(link* head)
{
  link* p1,*p2;

  p1=p2=head;

  if(head==null||head->next==null)
  {
      return head;
  }
  do
  {
      p1=p1->next;
      p2=p2->next->next;
  } while(p2&&p2->next)

      return p1;
}

//冒泡排序,大的往后冒

void Sort(int[] v)
{
   int j =1;

   while (j<v.lentgh-1)
    {
        for(i=0;i<v.length-j;i++)
        {
            if (v[i]>v[i+1])
            {
                v[i]^=v[i+1];
                v[i+1]^=v[i];
                v[i]^=v[i+1];
            }
        }
    }

}

j=1;i=0~v.length-1
j=2;i=0~v.length-2

posted on 2010-07-15 00:14  gracestoney  阅读(81)  评论(0编辑  收藏  举报