-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode-auto-edtr.cpp
More file actions
90 lines (90 loc) · 2.1 KB
/
code-auto-edtr.cpp
File metadata and controls
90 lines (90 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include<iostream>
#include<fstream>
#include<string>
#include<chrono>
#include<random>
#include<limits>
using namespace std;
mt19937 mt;
template<typename T>
T ilrand(T l=numeric_limits<T>::min(), T r=numeric_limits<T>::max())
{
return uniform_int_distribution<T>(l, r)(mt);
}
int main()
{
mt.seed(chrono::system_clock::now().time_since_epoch().count());
string fn,tp,nm;
cout<<"file path(name): "; cin>>fn;
fstream fin(fn,ios::in);
if(!fin)
{
cout<<"file not found\n";
return 0;
}
for(int i=fn.size()-1;i>=0;--i)
{
if(fn[i]=='.')
{
tp=fn.substr(i+1,100);
nm=fn.substr(0,i);
}
}
fstream fout(nm+".md",ios::out);
fout<<"```"<<tp<<"\n";
int cdtp,rspc,lth;
cout<<"Edit method? 1:anti-cheat code; 2:anti-cheat string; 3:both ";
cin>>cdtp;
cout<<"Code/String length? ";
cin>>lth;
cout<<"Number of spacing rows? ";
cin>>rspc;
int pow10=1;
for(int i=1;i<=lth;++i)
{
pow10*=10;
}
string nrow="",cod,str;
int cnt=0;
cout<<"Processing..."<<endl;
while(getline(fin,nrow))
{
cnt++;
if(cnt%rspc==0)
{
switch (cdtp)
{
case 1:
cod=to_string(ilrand<long long>(-pow10,pow10));
fout<<nrow<<"\ncode:"<<cod<<"\n";
break;
case 2:
str="";
for(int i=1;i<=lth;++i)
{
str+=ilrand<unsigned char>();
}
fout<<nrow<<"\nstr:"<<str<<"\n";
break;
default:
cod=to_string(ilrand<long long>(-pow10,pow10));
fout<<nrow<<"\ncode:"<<cod;
str="";
for(int i=1;i<=lth;++i)
{
str+=ilrand<unsigned char>();
}
fout<<" | str:"<<str<<"\n";
break;
}
}
else
{
fout<<nrow<<"\n";
}
}
fout<<"```";
cout<<"Done.\n";
getchar();
return 0;
}