android 用paint,canvas 繪圖

來源:互聯網
上載者:User

標籤:c++   快速排序   

#include <iostream>using namespace std;// quick sort  //另外,如果數組是引用傳遞可以通過函數模板的實參推斷來自動獲得它長度template<typename T,int N> void printArr(T (&arr)[N]){   int i = 0;     while(i<N)   {   cout << arr[i] <<" ";   i++;   }   cout <<endl;}void swap(int &p,int &q){int temp = p;p= q;q=temp;}int getIndex(int arr[],int nLow,int nHigh){int nTemp = arr[nHigh];int j = nLow - 1;for(int i=nLow;i<nHigh;i++){if ( arr[i] <= nTemp) {            j=j+1;swap(arr[j],arr[i]);}}swap(arr[j+1],arr[nHigh]);return j+1;}void quickSort(int arr[],int nLow,int nHigh){if (nLow < nHigh){int nIndex = getIndex(arr,nLow,nHigh);quickSort(arr,nLow,nIndex-1);quickSort(arr,nIndex + 1,nHigh);}}int main(){#ifdef __cpluspluscout <<"c++" <<endl;#elsecout <<"c " <<endl;#endifint arr[] = {52,49,80,36,14,75,58,56,57,78,42,22,22,44};    quickSort(arr,0,sizeof(arr)/sizeof(arr[0]));printArr(arr);return 0;}

http://www.cnblogs.com/pugang/archive/2012/06/27/2565093.html

具體邏輯見上面的連結

android 用paint,canvas 繪圖

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.