Compare commits
No commits in common. "2b0e4ffbd27417af39eeb283ff4e20d33eeb400d" and "eb850866576adf89f6e59cb7b07b5a690e8b1d33" have entirely different histories.
2b0e4ffbd2
...
eb85086657
@ -1,8 +1,4 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
<<<<<<< HEAD
|
|
||||||
#include <cstdlib>
|
|
||||||
=======
|
|
||||||
>>>>>>> eb850866576adf89f6e59cb7b07b5a690e8b1d33
|
|
||||||
#include<tools.hpp>
|
#include<tools.hpp>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
@ -11,44 +7,6 @@ void print_help(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(const int argc,const char *argv[]){
|
int main(const int argc,const char *argv[]){
|
||||||
<<<<<<< HEAD
|
|
||||||
if(argc==1){
|
|
||||||
print_help();
|
|
||||||
exit(-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()){
|
|
||||||
zt::eprint("The length of last two characters are not same!\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
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");
|
|
||||||
=======
|
|
||||||
std::string argv1(argv[1]);
|
std::string argv1(argv[1]);
|
||||||
if(argc==2){
|
if(argc==2){
|
||||||
if(argv1=="-h"){
|
if(argv1=="-h"){
|
||||||
@ -81,5 +39,4 @@ int main(const int argc,const char *argv[]){
|
|||||||
zt::print(argv1,"\n");
|
zt::print(argv1,"\n");
|
||||||
|
|
||||||
end:;
|
end:;
|
||||||
>>>>>>> eb850866576adf89f6e59cb7b07b5a690e8b1d33
|
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ostream>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#define NAME_VALUE(v)#v," : ",(v)
|
#define NAME_VALUE(v)#v," : ",(v)
|
||||||
@ -42,22 +41,10 @@ namespace zt {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
inline void print(std::ostream &os,const Args&...args){
|
void print(const Args&...args){
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
((ss<<args),...);
|
((ss<<args),...);
|
||||||
os<<ss.str();
|
std::cout<<ss.str();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename ...Args>
|
|
||||||
inline void print(const Args&...args){
|
|
||||||
print(std::cin,args...);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename ...Args>
|
|
||||||
inline void eprint(const Args&...args){
|
|
||||||
print(std::cerr,args...);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user