-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquine.cpp
More file actions
57 lines (57 loc) · 1.1 KB
/
quine.cpp
File metadata and controls
57 lines (57 loc) · 1.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
#include <iostream>
#include <vector>
using namespace std;
struct Super
{
vector<string> save;
void print(string str)
{
cout << str << endl;
save.push_back(str);
}
~Super(){
for(auto s:save) {
cout << "s.print(\"";
for(auto ch:s) {
if (ch == '"')
cout << "\\\"";
else if (ch == '\\')
cout << ch << ch;
else
cout << ch;
}
cout << "\");" << endl;
}
cout << '}';
}};
int main(){
Super s;
s.print("#include <iostream>");
s.print("#include <vector>");
s.print("using namespace std;");
s.print("struct Super");
s.print("{");
s.print("vector<string> save;");
s.print("void print(string str)");
s.print("{");
s.print("cout << str << endl;");
s.print("save.push_back(str);");
s.print("}");
s.print("~Super(){");
s.print("for(auto s:save) {");
s.print("cout << \"s.print(\\\"\";");
s.print("for(auto ch:s) {");
s.print("if (ch == '\"')");
s.print("cout << \"\\\\\\\"\";");
s.print("else if (ch == '\\\\')");
s.print("cout << ch << ch;");
s.print("else");
s.print("cout << ch;");
s.print("}");
s.print("cout << \"\\\");\" << endl;");
s.print("}");
s.print("cout << '}';");
s.print("}};");
s.print("int main(){");
s.print("Super s;");
}