This commit is contained in:
Zengtudor 2024-09-17 12:38:48 +08:00
commit fa5d59976e
1 changed files with 35 additions and 0 deletions

View File

@ -6,6 +6,40 @@ void print_help(){
} }
int main(const int argc,const char *argv[]){ int main(const int argc,const char *argv[]){
<<<<<<<<< Temporary merge branch 1
std::string argv1(argv[1]);
if(argc==2){
if(argv1=="-h"){
zt::print("help:\n","\tThis is a simple string replacer to replace characters of the same length.\n","\t<string> <character to be replaced> <character to replace>\n","\t\t-By Zengtudor\n");
}else{
print_help();
}
}else if(argc==4){
std::string_view be_replaced(argv[2]),to_replace(argv[3]);
if(be_replaced.size()!=to_replace.size()){
goto end;
}
for(auto i: zt::Range((size_t)0,argv1.size())){
if(argv1[i]==be_replaced[0]){
for(auto j: zt::Range((size_t)0,be_replaced.size())){
if(argv1[i+j]!=be_replaced[j]){
goto out_of_match;
}
}
for(auto j:zt::Range((size_t)0,be_replaced.size())){
argv1[i+j]=to_replace[j];
}
}
out_of_match:;
}
}else{
print_help();
}
zt::print(argv1,"\n");
end:;
=========
if(argc==1){ if(argc==1){
print_help(); print_help();
exit(-1); exit(-1);
@ -42,4 +76,5 @@ int main(const int argc,const char *argv[]){
} }
zt::print(argv1,"\n"); zt::print(argv1,"\n");
>>>>>>>>> Temporary merge branch 2
} }