一下午就费在写这个程序上了,好累,各种转义字符看得我眼睛花
编译运行以下代码,得到的输出就是代码本身,是不是觉得有点神奇
[mw_shl_code=cpp,true]#include *本站禁止HTML标签噢*
using namespace std;
int main() {
string x = "\tstring temp = \"\";\n\tfor(int j = 0; j < (int)x.size(); ++j) {\n\t\tif(x[j] == \'\\\\\' || x[j] == \'\\\"\' || x[j] == \'\\\'\') {\n\t\t\ttemp += \"\\\\\";\n\t\t\ttemp += x[j];\n\t\t}\n\t\telse if(x[j] == \'\\n\')\n\t\t\ttemp += \"\\\\n\";\n\t\telse if(x[j] == \'\\t\')\n\t\t\ttemp += \"\\\\t\";\n\t\telse\n\t\t\ttemp += x[j];\n\t}\n\tstring a = \"#include *本站禁止HTML标签噢* \\nusing namespace std;\\nint main() {\\n\\tstring x = \\\"\" + temp + \"\\\";\\n\";\n\tcout << a + x << endl;\n\treturn 0;\n}";
string temp = "";
for(int j = 0; j < (int)x.size(); ++j) {
if(x[j] == '\\' || x[j] == '\"' || x[j] == '\'') {
temp += "\\";
temp += x[j];
}
else if(x[j] == '\n')
temp += "\\n";
else if(x[j] == '\t')
temp += "\\t";
else
temp += x[j];
}
string a = "#include *本站禁止HTML标签噢* \nusing namespace std;\nint main() {\n\tstring x = \"" + temp + "\";\n";
cout << a + x << endl;
return 0;
}[/mw_shl_code]
