Skip to content

Commit c7a2123

Browse files
authored
Merge pull request #673 from adherent9870/newm
replace x by c
2 parents 9d3a9b2 + 3709bf2 commit c7a2123

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

LeetCode/replacecc.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
#include <string>
3+
using namespace std;
4+
void cc(string s,char a,char b){
5+
if(s.length()==0){
6+
return;
7+
}
8+
if (s[0]==a) {
9+
s[0]=b;
10+
cc(s.substr(1),a,b);
11+
}
12+
cc(s.substr(1),a,b);;
13+
}
14+
int main(){
15+
string s="asdfgh";
16+
char a='a',b='z';
17+
/* cin >> s;
18+
cin >> a >> b;
19+
*/
20+
cc(s,a,b);
21+
cout<<s;
22+
23+
}

0 commit comments

Comments
 (0)