正文
增加 16 行删除 564 行
4 行未改动567891011121314151612 行未改动29303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066074 行未改动代码抽象器是由 C++ 研发的,一款用于将原本正常的 C++ 代码,利用 C++ 中的特殊语法,修改为令人难以读懂的全新代码。能有效混淆代码,起到保护代码的作用。这一项目主张不改变代码的原本逻辑,在尽可能不影响代码的运行速度与占用内存的情况下最大程度混淆代码。目前有以下功能:- 添加随机缩进、随机注释、随机反斜杠和转换中括号、大括号等。- 将 `&&` 和 `||` 分别转换为 `and` 和 `or`。- 将 `&=` 转换为 `and_eq`、将 `|=` 转换为 `or_eq`、将 `^=` 转换为 `xor_eq`、将 `!=` 转换为 `not_eq`。- 将 `&` 转换为 `bitand`、将 `|` 转换为 `bitor`、将 `^` 转换为 `xor`、将 `!` 转换为 `not`、将 `~` 转换为 `compl`。- 将 `while` 转为 `for`。- 将字符转为数字。- 删除空行与有概率删除换行。12 行未改动测试一下代码是否正确。可以看到代码能够保持与抽象前一样的功能。## 三、下载可执行程序:[代码抽象器.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~~多多对本项目提出建议(可以直接在评论区指出)。fun fact:如果只保留抽象器中的 `erase_backslash(S);` 和 `erase_note(S);` 两行,那么它将会变为代码净化器。4 行未改动567891011121314151617181920212223242526272812 行未改动414243444546474849505152535455565758594 行未改动代码抽象器是由 C++ 研发的,一款用于将原本正常的 C++ 代码,利用 C++ 中的特殊语法,修改为令人难以读懂的全新代码。能有效混淆代码,起到保护代码的作用。这一项目主张不改变代码的原本逻辑,在尽可能不影响代码的运行速度与占用内存的情况下最大程度混淆代码。目前有以下功能:- 添加随机缩进。- 添加随机注释。- 添加随机反斜杠。- 将 `[]` 转换为 `<::>`。- 将 `{}` 转换为 `<%%>`。- 将 `#` 转换为 `%:`。- 将 `&&` 和 `||` 分别转换为 `and` 和 `or`。- 将 `&=` 转换为 `and_eq`。- 将 `|=` 转换为 `or_eq`。- 将 `^=` 转换为 `xor_eq`。- 将 `!=` 转换为 `not_eq`。- 将 `&` 转换为 `bitand`。- 将 `|` 转换为 `bitor`。- 将 `^` 转换为 `xor`。- 将 `!` 转换为 `not`。- 将 `~` 转换为 `compl`。- 将 `while` 转为 `for`。- 将字符转为数字。- 删除空行与有概率删除换行。12 行未改动测试一下代码是否正确。可以看到代码能够保持与抽象前一样的功能~~而且可读性极高~~。## 三、下载可执行程序:[代码抽象器.exe](https://www.luogu.com.cn/fe/api/problem/downloadAttachment/8wt7d7ca)。同时也可以在本地编译源码得到可执行程序。## 四、尾声本项目完全手写,没有借助 AI,所以制作过程不算容易,实现也较为粗糙。将来会继续完善和更新新的功能。同时本项目也可能存在 bug,希望大家能够~~养成在提交代码前抽象一下代码的习惯方便反馈 bug~~多多对本项目提出建议(可以直接在评论区指出)。