手機調用系統的拍照和裁剪功能,如果介面有輸入框EditText,在一些手機會出現點擊EditText會彈出IME,卻不能輸入的情況。

來源:互聯網
上載者:User

標籤:動態規劃   公用子串   

code如下:

//Longest common sequence, dynamic programming methodvoid FindLCS(char *str1, char *str2){if(str1 == NULL || str2 == NULL)return;int length1 = strlen(str1)+1;int length2 = strlen(str2)+1;int **csLength,**direction;//two arrays to record the length and directionint i,j,maxLength=0,maxI=0,maxJ=0;csLength = (int **)new int[length2];for(i=0; i<length1; i++)csLength[i] = (int *)new int[length1];for(i=0;i<length2;i++)for(j=0;j<length1;j++)csLength[i][j] = 0;direction = (int **)new int[length2];for(i=0; i<length1; i++)direction[i] = (int *)new int[length1];for(i=0;i<length2;i++)for(j=0;j<length1;j++)direction[i][j] = 0;for(i=1;i<length2;i++)for(j=1;j<length1;j++){if(str2[i-1] == str1[j-1]){csLength[i][j] = csLength[i-1][j-1] + 1;direction[i][j] = 3;//3 means leftup}else if(csLength[i-1][j] > csLength[i][j-1]){csLength[i][j] = csLength[i-1][j];direction[i][j] = 1;//1 means left}else{csLength[i][j] = csLength[i][j-1];direction[i][j] = 2;//2 means up}if(maxLength < csLength[i][j]){maxLength = csLength[i][j];//record th max length and the corresponding indexmaxI = i;maxJ = j;}}i = maxI;j = maxJ;//the output is in reverse orderwhile(i!=0 && j!= 0){if( str2[i-1] == str1[j-1])cout<<str2[i-1]<<" ";if(direction[i][j] == 3){i--;j--;}else if(direction[i][j] == 1){i--;}else if(direction[i][j] == 2){j--;}}}


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.