正在加载图片...
串联接:把两个串s1和s2首尾连接成一个新串s,即 1+s2。 /*设串结束用“\0’来标识。*/ int StrConcatl(SeqString sl, SeqString S2, SeqString S) char sl,s2口],s[]; i int i=0, j, len1, len2 len1= StrEngth(s1); len2-StrLength(s2) if(enl+len2> MAXSIZE-l) return0;/*s长度不够* while(sl[]=10,)(sli=s1[]; i++: j++,) j=0; while(s2[]=10,)(s[i]=s2[]; 1++: j++,) 1=10, return 1 O(n)1.串联接:把两个串s1和s2首尾连接成一个新串s ,即:s<=s1+s2。 /*设串结束用‘\0’来标识。*/ int StrConcat1(SeqString s1, SeqString s2, SeqString s) char s1[],s2[],s[]; { int i=0 , j, len1, len2; len1= StrLength(s1); len2= StrLength(s2) if (len1+ len2>MAXSIZE-1) return 0 ; /* s长度不够*/ j=0; while(s1[j]!=’\0’) { s[i]=s1[j];i++; j++; } j=0; while(s2[j]!=’\0’) { s[i]=s2[j];i++; j++; } s[i]=’\0’; return 1; } O(n)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有