在字串中刪除特定的字元

2021-08-20 13:42:18 字數 482 閱讀 8099

在字串中刪除特定的字元(字串)。 題目:輸入兩個字串,從第一字串中刪除第二個字串中所有的字元。

例如,輸入」they are students.」和」aeiou」, 則刪除之後的第乙個字串變成」thy r stdnts.」。

#include #include char * string_del_characters( char * const src, const char * const dest )

; char * p = src;

int index = 0;

for( int i = 0; i < destlen; i++ )

while( *p != '\0' )

p++;

}src[index] = '\0';

return src;

}int main( int argc, char ** argv )

在字串中刪除特定字元

第一種方法 遍歷原陣列,在待刪陣列裡遍歷是否刪除該元素 char removechars char str,const char remove if state temp count str i state true i temp count 0 return temp 第二種方法 時間複雜度o n...

在字串中刪除特定的字元(字串)。

題目 輸入兩個字串,從第一字串中刪除第二個字串中所有的字元。例如,輸入 they are students.和 aeiou 則刪除之後的第乙個字串變成 thy r stdnts.其實這類題有個特點,字串中的字元分為兩類,就可以聯想快速排序裡的將當前的陣列分為左右兩組,其中左邊的數字小於某值,右邊的數...

在字串中刪除特定的字元

題目 輸入兩個字串,從第一字串中刪除第二個字串中所有的字元。例如,輸入 they are students.和 aeiou 則刪除之後的第乙個字串變成 thy r stdnts.分析 這是一道微軟面試題。在微軟的常見面試題中,與字串相關的題目佔了很大的一部分,因為寫程式操作字串能很好的反映我們的程式...