【正文】
RROR。 } else { if (!(=(char *) malloc(i*sizeof(char)))) return ERROR。 char *c。 實(shí)現(xiàn)樸素的模式匹配算法。二、 實(shí)驗(yàn)內(nèi)容設(shè)計一個算法,刪去串s中從第i個字符開始的連續(xù)j個字符(以堆分配法表示串)。被加密為39。 //串長} HString。i++,c++)。 } return OK。\039。}/* run this program using the console pauser or add your own getch, system(pause) or input loop */int main(){ HString S。 strDelete(S,3,4)。Status strAssign(HString amp。 =0。S1,HString amp。 else m++。 gets(str2)。typedef struct{ //堆分配法表示串的類型定義 char *ch。 for (i=0,c=chars。ji。 while(i=n) { switch([i]) { case 39。g39。d39。break。:[i]=39。 case 39。u39。l39。break。:[i]=39。 case 39。w39。t39。break。:[i]=39。 case 39。j39。s)//將輸入的字符串解密后輸出{ int i=0。 case 39。c39。t39。break。:[i]=39。 case 39。k39。l39。break。:[i]=39。 case 39。s39。y39。break。:[i]=39。 case 39。i++) printf(%c,[i])。 printf(加密后的字符串為:)。}樸素模式的匹配include //樸素的模式匹配include include includedefine OK 1define ERROR 0typedef int Status。++i,++c)。 while(i=S[0]amp。 }int main(){ HString s,t。 scanf(%d,amp。做第四題匹配模式的時候我參考了書上的程序,可發(fā)現(xiàn)書上用的是數(shù)組,我又把相關(guān)語句改成串,可最后不能運(yùn)行,我最終也沒有找到原因,希望老師可以解答一下。 strAssign(s,str1)。 int n,k。j=T[0]) { if(S[i]==T[j]) { ++i。 else { for(j=0。Status strAssign(HString amp。 printf(請輸入加密的字符串:)。} int main(){ HString s,t。:[i]=39。break。v39。u39。 case 39。:[i]=39。break。p39。m39。 case 39。:[i]=39。break。o39。e39。 case 39。:[i]=39。 n=StrLength(s)。 } i++