c/C++编程
让用护任意输入3个字符串,将第1个字符串中出现的第2个字符串用第3个字符串代替,输出最终字符串 编程问题,用C或C++都可以,用函数更好
int main( ) { string s, s1, s2; cout<<"请输入原始串,以换行结束:"; getline( cin, s ); cout<<"请输入要查找的串,以换行结束:"; getline( cin, s1 ); cout<<"请输入要替换的串,以换行结束:"; getline( cin, s2 ); size_t pos = nd( s1 ); while ( pos != string::npos )//表示找到了 { place( pos, ze(), s2 ); //替换 pos = nd( s1, pos + ze()); //更新下次查找的位置,如果不做此步,可能死循环(当s2包含s1时) } cout<<"替换以后的串为"<
答:判断一个用一个数记录就行了详情>>
问:挺简单的一C函数,不过我是初学者,暂时还不会写,请好心人多多帮忙!
答:int mystrlen(char *str) { int n = 0; while (*str) { n++; str++;} return n; } voi...详情>>