tags: Programming 題目佔存

HW4-1

Description

此題節錄至東華資工 online judge,上學期 week 12 - 3
http://134.208.3.66/problem/PR110-12-03

請完成下列函數,replace 以及 replaceAll,函數的定義如下

char *replace(char *source, char *pattern, char *replacement);

函數 replace 會在字串 source 中找到第一個出現的 pattern 然後將它替換成 replacement 並回傳字串source
char *replaceAll(char *source, char *pattern, char *replacement);

函數 replace 會在字串 source 中找到所有的的 pattern 然後將它們全部都替換成 replacement 並回傳字串source


Please finish the function replace and function replaceAll.

char *replace(char *source, char *pattern, char *replacement);

char *replaceAll(char *source, char *pattern, char *replacement);

Function replace will find the first appear pattern in source and replace it withreplacement.

Function replaceAll will find all pattern in source and replace it with replacement.

Sample Input and Output