-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflames.cpp
More file actions
102 lines (72 loc) · 1.79 KB
/
flames.cpp
File metadata and controls
102 lines (72 loc) · 1.79 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
91
92
93
94
95
96
97
98
99
100
101
102
#include <iostream>
#include <algorithm>
using namespace std;
string status(char x) {
string rel;
switch(x) {
case 'F': rel = "Friendship";
break;
case 'L': rel = "Love";
break;
case 'A': rel = "Affair";
break;
case 'M': rel = "Marriage";
break;
case 'E': rel = "Enmity";
break;
case 'S': rel = "Sex";
break;
}
return rel;
}
void generateFlames(int ctr) {
string s = "FLAMES";
for (int i = 6, j = 1; i > 1; i--, j++) {
int temp = ctr % i;
cout << endl << "Iteration[" << j << "] : " << s;
if (temp == 0) {
temp = i;
}
s.erase(remove(s.begin(), s.end(), s.at(temp - 1)), s.end());
string s1 = s.substr(temp - 1, s.length() - temp + 1);
string s2 = s.substr(0, temp - 1);
s = s1 + s2;
}
cout << endl << "Iteration[6] : " << s << endl;
cout << endl << "Relationship : " << status(s[0]) << endl;
return ;
}
void removeCommon(string name[]) {
for (string::iterator i = name[0].begin(); i != name[0].end(); i++) {
for (string::iterator j = name[1].begin(); j != name[1].end(); j++) {
if (*i == *j) {
*i = '*';
*j = '*';
break;
}
}
}
string x = name[0] + name[1];
x.erase(remove(x.begin(), x.end(), '*'), x.end());
int ctr = x.length();
generateFlames(ctr);
return ;
}
void inputProcess() {
string name[2];
for (int i = 0; i < 2; i++) {
cout << "Enter name[" << (i + 1) << "] : ";
getline(cin, name[i]);
name[i].erase(remove(name[i].begin(), name[i].end(), ' '), name[i].end());
name[i].erase(remove(name[i].begin(), name[i].end(), '-'), name[i].end());
name[i].erase(remove(name[i].begin(), name[i].end(), '\''), name[i].end());
transform(name[i].begin(), name[i].end(), name[i].begin(), ::tolower);
}
removeCommon(name);
return ;
}
int main()
{
inputProcess();
return 0;
}