标签:华为入职练习 华为oj
#include <stdlib.h> #include <string.h> #include "oj.h" #include <iostream> using namespace std; /* 功能: 输入: 输出: 返回:成功0,其它-1 */ int ProcessString( char * strInput,char chSrc,char chDes ,char * strOutput) { if (NULL == strInput || NULL == strOutput) { return -1; } int flag = 0; int iCur =0; while ('\0' != strInput[iCur]) { if (strInput[iCur] == chSrc) { strOutput[iCur] = chDes; flag = 0; } else { strOutput[iCur] = strInput[iCur]; } iCur ++; } strOutput[iCur] = '\0'; if (1 == flag) { return 0; } else { return -1; } } int main() { char strInput[] = "d545a"; char strSrc[] = "d545c"; char strOutput[10] = ""; ProcessString(strInput,'a','c',strOutput); cout<<strInput<<endl<<strOutput<<endl; return 0; }
标签:华为入职练习 华为oj
原文地址:http://blog.csdn.net/xiaohanstu/article/details/42459487