版本比较
代码抽象器
正文
增加 0 行删除 558 行
48 行未改动495051525353555657545960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612555657585948 行未改动可执行程序:[代码抽象器.exe](https://www.luogu.com.cn/fe/api/problem/downloadAttachment/8wt7d7ca)。
同时也可以在本地编译源码得到可执行程序。
::::info[源码]
```cpp#include <bits/stdc++.h>#include <windows.h>
using namespace std;
map <string, bool> Define;string s, S;string monkeytype[250] = {"zdjd", "dijkstra", "log", "primal-dual", "edmonds-karp", "SPFA", "florr.io", "floor", "floyd", "dinic", "ff", "ffa", "generals.io", "segment", "tree", "tree", "beats", "DAG", "flow", "long long", "long long int", "FFT", "NTT", "Tarjan" , "double", "CPU", "GPU", "GPT", "deepseek", "deekseep", "AI GENERATED", "ds", "dsa", "dsa", "dsa", "PPT", "mine", "craft", "subtree", "subtask" , "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "ls", "rs", "l", "r", "mid", "pushup", "pushdown", ",merge", "modify", "query" , "build", "subtask n", "sigma", "ans", "sum", "+=", "*=", "-=", "/=", "^=", "&=", "bitset", "|=", "%=", "+", "-", "=", "*", "/", "%", "^", "&", "|", "}", "{", "]", "[", ".size", "function", "triangle", "love", "love", "float", "string", "substring", "subline", "kskbl", "TLE", "MLE", "RE", "WA", "WA+TLE", "TLE+MLE", "TrueGod", "SE", "PE", "line", "linux", "NOI", "NOIP", "CSP-J", "CSP-S", "CTS", "CTT", "IOI", "simulator", "114514", "1919819", "mul", "dist" , "a-z", "logn", "n^2", "n", "n/2", "dp", "johnson", "random", "rand", "rand()", "STL", "queue", "map", "unordered_map", "ST", "stack", "priority_queue", "deque", "mutable", "set", "games", "steam", "slay", "the", "a", "spire", "cat", "super auto pets", "driver", "florr.io", "generals.io", "zhihu.com", ".com", ".cn", ".wiki", ".top", ".org", ".ac", ".wa", "something", "KD-tree", "lazytag", "u", "u << 1", "u << 1 | 1", "fa", "n", "m", "s", "t", "x", "y", "max", "min", "mex", "wax", "bitwise", "xor", "or", "ans", "not", "cnt", "ak!!!", "ac", "akioi", "cout", "return", "-1", "cerr", "cin", "printf", "scanf", "ios_base", "sync", "tie", "bot", "team", "rank", "ranking", "rp", "rating", ">>", "<<", ";", ":", "(", "!", ")", "?", "_", "qwq", "<", ">", "struct", "node", "dep", ".", ".", ".", ".", ".", "++", "--", "==", "duel", "orz", "orz", "sto", "qp", "zc", "lol", "std", "main", "miao", "mian", "time(0)", "srand", "code", "True", "God", "tag", "OI", "OIER", "AFO", "point", "pts", "leaf", "value", "int"};mt19937 rd(chrono :: duration_cast <chrono :: nanoseconds> (chrono :: system_clock :: now().time_since_epoch()).count());int rd_int(int l, int r) { std :: uniform_int_distribution <int> dist(l, r); return dist(rd); }
string Random_Word() { return monkeytype[rd_int(0, 248)]; }string Random_String() { string res; for (int i = rd_int(1, 8); i >= 1; i--) res += Random_Word() + ' '; return res; }int Count_Backslash(string &s, int pos) { int res = 0; for (int i = pos - 1; i >= 0 and s[i] == '\\'; i--) res++; return res; }bool Check_Number(char c) { return (c >= '0' and c <= '9'); }bool Check_Letter(char c) { return ((c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z')); }bool Check_Underline(char c) { return (c == '_'); }bool Check_Key(char c) { return (Check_Number(c) or Check_Letter(c) or Check_Underline(c)); }bool Check_Legal(string &s, int pos) { return !(Count_Backslash(s, pos) & 1); }bool Check_End(string &s, int pos) { return (pos == s.size() - 1); }bool Check_Begin(string &s, int pos) { return (pos == 0); }bool Check_Define(string x) { return Define[x]; }void Erase_String(string &s, int l, int r) { if (l > r) return ; s.erase(l, r - l + 1); }/* 找 pos 之后的第一个双引号 */ int Find_Double_Quotation(string &s, int pos) { for (int i = pos + 1; i < s.size(); i++) { if (s[i] == '\"' and Check_Legal(s, i)) return i; } return pos;}/* 找 pos 之后的第一个单引号 */ int Find_Single_Quotation(string &s, int pos) { for (int i = pos + 1; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) return i; } return pos;}/* 找 pos 之后的第一个右括号 */ int Find_Right_Parentheses(string &s, int pos) { int cnt = 1; for (int i = pos + 1; i < s.size(); i++) { if (s[i] == '(') cnt++; if (s[i] == ')') cnt--; if (!cnt) return i; } return -1;}/* 找 pos 之后的第一个换行 */ int Find_Enter(string &s, int pos) { for (int i = pos + 1; i < s.size(); i++) { if (s[i] == '\n') return i; } return s.size();}/* 找 pos 之前的第一个换行 */ int Find_Last_Enter(string &s, int pos) { for (int i = pos - 1; i >= 0; i--) { if (s[i] == '\n') return i; } return -1;}/* 判断 pos 和 pos + 1 两个位置是否构成单行注释 */ bool Check_Single_Line_Note(string &s, int pos) { if (Check_End(s, pos) or s[pos] != '/' or s[pos + 1] != '/') return 0; return 1; }/* 判断 pos 和 pos + 1 两个位置是否构成多行注释 */ bool Check_Serval_Line_Note(string &s, int pos) { if (Check_End(s, pos) or s[pos] != '/' or s[pos + 1] != '*') return 0; return 1;}/* 找 pos 之后第一个多行注释的结束 */ int Find_Serval_Line_Note(string &s, int pos) { for (int i = pos + 1; i < s.size(); i++) { if (!Check_Begin(s, i) and s[i - 1] == '*' and s[i] == '/') return i; } return s.size() - 1;}/* 找 pos 之前第一个有意义字符的位置 */ int Find_Last_Char(string &s, int pos) { for (int i = pos - 1; i >= 0; i--) { if (s[i] != '\t' and s[i] != '\n' and s[i] != ' ') return i; } return -1;}/* 找 pos 之后第一个有意义字符的位置 */ int Find_Next_Char(string &s, int pos) { for (int i = pos + 1; i < s.size(); i++) { if (s[i] != '\t' and s[i] != '\n' and s[i] != ' ') return i; } return -1;}/* 截取 pos 之后的最长可能变量名 */ string Cut_String(string &s, int pos) { string res; for (int i = pos; i < s.size() and Check_Key(s[i]); i++) res += s[i]; return res;}/* 截取 l ~ r 的子串 */ string Cut_Substr(string &s, int l, int r) { if (l > r) return ""; return s.substr(l, r - l + 1); }/* 将数字转为字符串 */ string Number_To_String(int x) { string res; while (x) { res += (x % 10) + '0'; x /= 10; } reverse(res.begin(), res.end()); return res;}void erase_backslash(string &s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '\n') { int p = Find_Last_Char(s, i); if (p != -1 and s[p] == '\\') { Erase_String(s, i, i), Erase_String(s, p, p); i -= 2; } } }}void erase_note(string &s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (Check_Single_Line_Note(s, i)) { Erase_String(s, i, Find_Enter(s, i) - 1); s.insert(i, " "); } if (Check_Serval_Line_Note(s, i)) { Erase_String(s, i, Find_Serval_Line_Note(s, i + 2)); s.insert(i, " "); } }}void save_define(string &s) { if (s.size() >= 7) { for (int i = 0; i + 6 < s.size(); i++) { if (s.substr(i, 7) == "#define") { int pos = Find_Next_Char(s, i + 6); if (pos != -1) Define[Cut_String(s, pos)] = 1; } } }}void change_bracket(string &s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (s[i] == '[' and rd_int(1, 10) <= 9) s.replace(i, 1, "<:"); if (s[i] == ']' and rd_int(1, 10) <= 9) s.replace(i, 1, ":>"); if (s[i] == '{' and rd_int(1, 10) <= 9) s.replace(i, 1, "<%"); if (s[i] == '}' and rd_int(1, 10) <= 9) s.replace(i, 1, "%>"); }}void change_hashsign(string &s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (s[i] == '#') s.replace(i, 1, "%:"); }}void change_while(string &s) { if (Check_Define("for") or Check_Define("while")) return ; if (s.size() >= 5) { for (int i = 0; i + 4 < s.size(); i++) { if (s.substr(i, 5) == "while") { int p1 = Find_Last_Char(s, i), p2 = Find_Next_Char(s, i + 4); if ((p1 == -1 or !Check_Key(s[p1])) and p2 != -1 and s[p2] == '(') { int p3 = Find_Right_Parentheses(s, p2); if (p3 == -1) continue; string tmp = "for"; for (int i = rd_int(0, 2); i >= 1; i--) tmp += ' '; tmp += '('; for (int i = rd_int(0, 2); i >= 1; i--) tmp += ' '; tmp += ';'; for (int i = rd_int(0, 2); i >= 1; i--) tmp += ' '; tmp += Cut_Substr(s, p2 + 1, p3 - 1); for (int i = rd_int(0, 2); i >= 1; i--) tmp += ' '; tmp += ';'; for (int i = rd_int(0, 2); i >= 1; i--) tmp += ' '; tmp += ')'; Erase_String(s, i, p3); s.insert(i, tmp); } } } }}void change_and(string &s) { if (Check_Define("and")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (rd_int(1, 48) <= 38 and !Check_End(s, i) and s[i] == '&' and s[i + 1] == '&') { if (Check_Begin(s, i) and Check_End(s, i + 1)) s.replace(i, 2, "and"); else if (Check_Begin(s, i)) { if (s[i + 2] == ' ') s.replace(i, 2, "and"); else s.replace(i, 2, "and "); } else if (Check_End(s, i + 1)) { if (s[i - 1] == ' ') s.replace(i, 2, "and"); else s.replace(i, 2, " and"); } else { if (s[i - 1] == ' ' and s[i + 2] == ' ') s.replace(i, 2, "and"); else if (s[i - 1] == ' ') s.replace(i, 2, "and "); else if (s[i + 2] == ' ') s.replace(i, 2, " and"); else s.replace(i, 2, " and "); } } }}void change_or(string &s) { if (Check_Define("or")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (rd_int(1, 48) <= 38 and !Check_End(s, i) and s[i] == '|' and s[i + 1] == '|') { if (Check_Begin(s, i) and Check_End(s, i + 1)) s.replace(i, 2, "or"); else if (Check_Begin(s, i)) { if (s[i + 2] == ' ') s.replace(i, 2, "or"); else s.replace(i, 2, "or "); } else if (Check_End(s, i + 1)) { if (s[i - 1] == ' ') s.replace(i, 2, "or"); else s.replace(i, 2, " or"); } else { if (s[i - 1] == ' ' and s[i + 2] == ' ') s.replace(i, 2, "or"); else if (s[i - 1] == ' ') s.replace(i, 2, "or "); else if (s[i + 2] == ' ') s.replace(i, 2, " or"); else s.replace(i, 2, " or "); } } }}void change_xor(string &s) { if (Check_Define("xor")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (rd_int(1, 48) <= 38 and s[i] == '^' and (Check_End(s, i) or s[i + 1] != '=')) { if (Check_Begin(s, i) and Check_End(s, i)) s.replace(i, 1, "xor"); else if (Check_Begin(s, i)) { if (s[i + 1] == ' ') s.replace(i, 1, "xor"); else s.replace(i, 1, "xor "); } else if (Check_End(s, i)) { if (s[i - 1] == ' ') s.replace(i, 1, "xor"); else s.replace(i, 1, " xor"); } else { if (s[i - 1] == ' ' and s[i + 1] == ' ') s.replace(i, 1, "xor"); else if (s[i - 1] == ' ') s.replace(i, 1, "xor "); else if (s[i + 1] == ' ') s.replace(i, 1, " xor"); else s.replace(i, 1, " xor "); } } }}void change_not(string &s) { if (Check_Define("not")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (rd_int(1, 48) <= 38 and s[i] == '!' and (Check_End(s, i) or s[i + 1] != '=')) { if (Check_Begin(s, i) and Check_End(s, i)) s.replace(i, 1, "not"); else if (Check_Begin(s, i)) { if (s[i + 1] == ' ') s.replace(i, 1, "not"); else s.replace(i, 1, "not "); } else if (Check_End(s, i)) { if (s[i - 1] == ' ') s.replace(i, 1, "not"); else s.replace(i, 1, " not"); } else { if (s[i - 1] == ' ' and s[i + 1] == ' ') s.replace(i, 1, "not"); else if (s[i - 1] == ' ') s.replace(i, 1, "not "); else if (s[i + 1] == ' ') s.replace(i, 1, " not"); else s.replace(i, 1, " not "); } } }}void change_and_eq(string &s) { if (Check_Define("and_eq")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (rd_int(1, 48) <= 38 and !Check_End(s, i) and s[i] == '&' and s[i + 1] == '=') { if (Check_Begin(s, i) and Check_End(s, i + 1)) s.replace(i, 2, "and_eq"); else if (Check_Begin(s, i)) { if (s[i + 2] == ' ') s.replace(i, 2, "and_eq"); else s.replace(i, 2, "and_eq "); } else if (Check_End(s, i + 1)) { if (s[i - 1] == ' ') s.replace(i, 2, "and_eq"); else s.replace(i, 2, " and_eq"); } else { if (s[i - 1] == ' ' and s[i + 2] == ' ') s.replace(i, 2, "and_eq"); else if (s[i - 1] == ' ') s.replace(i, 2, "and_eq "); else if (s[i + 2] == ' ') s.replace(i, 2, " and_eq"); else s.replace(i, 2, " and_eq "); } } }}void change_or_eq(string &s) { if (Check_Define("or_eq")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (rd_int(1, 48) <= 38 and !Check_End(s, i) and s[i] == '|' and s[i + 1] == '=') { if (Check_Begin(s, i) and Check_End(s, i + 1)) s.replace(i, 2, "or_eq"); else if (Check_Begin(s, i)) { if (s[i + 2] == ' ') s.replace(i, 2, "or_eq"); else s.replace(i, 2, "or_eq "); } else if (Check_End(s, i + 1)) { if (s[i - 1] == ' ') s.replace(i, 2, "or_eq"); else s.replace(i, 2, " or_eq"); } else { if (s[i - 1] == ' ' and s[i + 2] == ' ') s.replace(i, 2, "or_eq"); else if (s[i - 1] == ' ') s.replace(i, 2, "or_eq "); else if (s[i + 2] == ' ') s.replace(i, 2, " or_eq"); else s.replace(i, 2, " or_eq "); } } }}void change_xor_eq(string &s) { if (Check_Define("xor_eq")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (rd_int(1, 48) <= 38 and !Check_End(s, i) and s[i] == '^' and s[i + 1] == '=') { if (Check_Begin(s, i) and Check_End(s, i + 1)) s.replace(i, 2, "xor_eq"); else if (Check_Begin(s, i)) { if (s[i + 2] == ' ') s.replace(i, 2, "xor_eq"); else s.replace(i, 2, "xor_eq "); } else if (Check_End(s, i + 1)) { if (s[i - 1] == ' ') s.replace(i, 2, "xor_eq"); else s.replace(i, 2, " xor_eq"); } else { if (s[i - 1] == ' ' and s[i + 2] == ' ') s.replace(i, 2, "xor_eq"); else if (s[i - 1] == ' ') s.replace(i, 2, "xor_eq "); else if (s[i + 2] == ' ') s.replace(i, 2, " xor_eq"); else s.replace(i, 2, " xor_eq "); } } }}void change_not_eq(string &s) { if (Check_Define("not_eq")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (rd_int(1, 48) <= 38 and !Check_End(s, i) and s[i] == '!' and s[i + 1] == '=') { if (Check_Begin(s, i) and Check_End(s, i + 1)) s.replace(i, 2, "not_eq"); else if (Check_Begin(s, i)) { if (s[i + 2] == ' ') s.replace(i, 2, "not_eq"); else s.replace(i, 2, "not_eq "); } else if (Check_End(s, i + 1)) { if (s[i - 1] == ' ') s.replace(i, 2, "not_eq"); else s.replace(i, 2, " not_eq"); } else { if (s[i - 1] == ' ' and s[i + 2] == ' ') s.replace(i, 2, "not_eq"); else if (s[i - 1] == ' ') s.replace(i, 2, "not_eq "); else if (s[i + 2] == ' ') s.replace(i, 2, " not_eq"); else s.replace(i, 2, " not_eq "); } } }}void change_compl(string &s) { if (Check_Define("compl")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (rd_int(1, 48) <= 38 and s[i] == '~') { if (Check_Begin(s, i) and Check_End(s, i)) s.replace(i, 1, "compl"); else if (Check_Begin(s, i)) { if (s[i + 1] == ' ') s.replace(i, 1, "compl"); else s.replace(i, 1, "compl "); } else if (Check_End(s, i)) { if (s[i - 1] == ' ') s.replace(i, 1, "compl"); else s.replace(i, 1, " compl"); } else { if (s[i - 1] == ' ' and s[i + 1] == ' ') s.replace(i, 1, "compl"); else if (s[i - 1] == ' ') s.replace(i, 1, "compl "); else if (s[i + 1] == ' ') s.replace(i, 1, " compl"); else s.replace(i, 1, " compl "); } } }}void change_bitand(string &s) { if (Check_Define("bitand")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (rd_int(1, 48) <= 38 and s[i] == '&' and (Check_End(s, i) or (s[i + 1] != '=' and s[i + 1] != '&')) and (Check_Begin(s, i) or s[i - 1] != '&')) { if (Check_Begin(s, i) and Check_End(s, i)) s.replace(i, 1, "bitand"); else if (Check_Begin(s, i)) { if (s[i + 1] == ' ') s.replace(i, 1, "bitand"); else s.replace(i, 1, "bitand "); } else if (Check_End(s, i)) { if (s[i - 1] == ' ') s.replace(i, 1, "bitand"); else s.replace(i, 1, " bitand"); } else { if (s[i - 1] == ' ' and s[i + 1] == ' ') s.replace(i, 1, "bitand"); else if (s[i - 1] == ' ') s.replace(i, 1, "bitand "); else if (s[i + 1] == ' ') s.replace(i, 1, " bitand"); else s.replace(i, 1, " bitand "); } } }}void change_bitor(string &s) { if (Check_Define("bitor")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (rd_int(1, 48) <= 38 and s[i] == '|' and (Check_End(s, i) or (s[i + 1] != '=' and s[i + 1] != '|')) and (Check_Begin(s, i) or s[i - 1] != '|')) { if (Check_Begin(s, i) and Check_End(s, i)) s.replace(i, 1, "bitor"); else if (Check_Begin(s, i)) { if (s[i + 1] == ' ') s.replace(i, 1, "bitor"); else s.replace(i, 1, "bitor "); } else if (Check_End(s, i)) { if (s[i - 1] == ' ') s.replace(i, 1, "bitor"); else s.replace(i, 1, " bitor"); } else { if (s[i - 1] == ' ' and s[i + 1] == ' ') s.replace(i, 1, "bitor"); else if (s[i - 1] == ' ') s.replace(i, 1, "bitor "); else if (s[i + 1] == ' ') s.replace(i, 1, " bitor"); else s.replace(i, 1, " bitor "); } } }}void change_char(string &s) { if (Check_Define("char")) return ; for (int i = 0; i < s.size(); i++) { if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (s[i] == '\'' and Check_Legal(s, i)) { int p = Find_Single_Quotation(s, i); if (p != i + 2 or rd_int(1, 48) <= 38) { i = p; continue; } char c = s[i + 1]; string tmp = "( (char ) (" + Number_To_String((int)(c)) + " ) )"; s.replace(i, 3, tmp); i += tmp.size(); continue; } }}void change_tab(string &s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (s[i] == '\n') { int pos = i + 1, time = rd_int(0, 10); string tmp; for (; pos < s.size() and (s[pos] == ' ' or s[pos] == '\t'); pos++); Erase_String(s, i + 1, pos - 1); for (int i = 1; i <= time; i++) tmp += ' '; s.insert(i + 1, tmp); } }}void erase_empty_line(string &s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (s[i] == '\n') { int p1 = Find_Next_Char(s, i), p2 = Find_Enter(s, i); if (p2 == s.size()) continue; if (p1 == -1 or p1 > p2) Erase_String(s, i + 1, p2), i--; } }}void erase_enter(string &s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (s[i] == '\n' and rd_int(1, 48) <= 38) { int p1 = Find_Next_Char(s, i), p2 = Find_Next_Char(s, Find_Last_Enter(s, i)); if (p1 == -1 or p1 >= Find_Enter(s, i) or p2 == -1 or p2 >= Find_Enter(s, Find_Last_Enter(s, i))) continue; if (s[p1] != '#' and s[p1] != '%' and s[p2] != '#' and s[p2] != '%') Erase_String(s, i, i), i--; } }}void insert_note(string &s) { for (int i = 0; i < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (Check_Serval_Line_Note(s, i)) { i = Find_Serval_Line_Note(s, i); continue; } if (s[i] == ' ') { if (rd_int(1, 78) == 1) { string tmp = "/* " + Random_String() + " */"; s.insert(i + 1, tmp); i += tmp.size(); } } } for (int i = 0; i < s.size(); i++) { if (s[i] == '\n' and rd_int(1, 10) == 1) { string tmp = "// " + Random_String(); s.insert(i, tmp); i += tmp.size(); } }}void insert_backslash(string &s) { for (int i = 0; i + 1 < s.size(); i++) { if (s[i] == '\'' and Check_Legal(s, i)) { i = Find_Single_Quotation(s, i); continue; } if (s[i] == '\"' and Check_Legal(s, i)) { i = Find_Double_Quotation(s, i); continue; } if (Check_Serval_Line_Note(s, i)) { i = Find_Serval_Line_Note(s, i); continue; } if (i <= 50) { if (rd_int(1, 5) == 1) s.insert(i + 1, "\\\n"), i += 2; } else { if (rd_int(1, 78) == 1) s.insert(i + 1, "\\\n"), i += 2; } }}bool copy_to_clipboard(const string &s) { if (OpenClipboard(NULL)) { EmptyClipboard(); HGLOBAL clip_buffer = GlobalAlloc(GMEM_DDESHARE, s.size() + 1); char *buffer = (char *)(GlobalLock(clip_buffer)); strcpy(buffer, s.c_str()); SetClipboardData(CF_TEXT, clip_buffer); CloseClipboard(); return 1; } return 0;}
int main() { while (getline(cin, s)) S += s + '\n'; erase_backslash(S); erase_note(S); save_define(S); change_bracket(S); change_hashsign(S); change_while(S); change_and(S); change_or(S); change_xor(S); change_not(S); change_and_eq(S); change_or_eq(S); change_xor_eq(S); change_not_eq(S); change_compl(S); change_bitand(S); change_bitor(S); change_char(S); change_tab(S); erase_empty_line(S); erase_enter(S); insert_note(S); insert_backslash(S); if (copy_to_clipboard(S)) cout << "Copied successful. The code has been copied to the clipboard.\n" << flush; else { cout << "Copy failed. The code has been output to \"strange code.txt\", please search for the file in the current file path.\n" << flush; fstream out; out.open("strange code.txt", ios :: out); out << S << flush; } system("pause"); return 0;}```::::
## 四、尾声
本项目完全手写,没有借助 AI,所以制作过程不算容易,实现也较为粗糙。将来会继续完善和更新新的功能。
同时本项目也可能存在 bug,希望大家能够~~养成在提交代码前抽象一下代码的习惯方便反馈 bug~~多多对本项目提出建议(可以直接在评论区指出)。