-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUntitled2.cpp
More file actions
107 lines (88 loc) · 2.3 KB
/
Untitled2.cpp
File metadata and controls
107 lines (88 loc) · 2.3 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
103
104
105
106
107
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h> // for usleep
#include <time.h>
void typePrint(const char *s,int delay_ms){
for(int i=0;s[i];i++){
putchar(s[i]);
fflush(stdout);
usleep(delay_ms*1000);
}
}
void cleanStr(char *s){
int j=0;
for(int i=0;s[i];i++){
if(s[i]!=' ') s[j++]=tolower(s[i]);
}
s[j]='\0';
}
int countRemaining(char a[], char b[]){
int used[200]={0}, count=0;
for(int i=0;a[i];i++){
int found=0;
for(int j=0;b[j];j++){
if(!used[j] && a[i]==b[j]){
used[j]=1;
found=1;
break;
}
}
if(!found) count++;
}
for(int j=0;b[j];j++){
if(!used[j]) count++;
}
return count;
}
char* mapResult(char c){
switch(c){
case 'F': return "Friends";
case 'L': return "Love";
case 'A': return "Affection";
case 'M': return "Marriage";
case 'E': return "Enemies";
case 'S': return "Siblings";
}
return "Unknown";
}
void flamesAnimation(int count){
char flames[]="FLAMES";
int len=6;
typePrint("Calculating FLAMES", 100);
for(int i=0;i<3;i++){ printf("."); fflush(stdout); usleep(300000); }
printf("\n\n");
while(len>1){
int removeIndex=(count%len)-1;
if(removeIndex<0) removeIndex=len-1;
printf("Removing: %c\n", flames[removeIndex]);
usleep(400000);
for(int k=removeIndex;k<len-1;k++){
flames[k]=flames[k+1];
}
len--;
}
printf("\nFinal Letter: %c\n", flames[0]);
printf("Result: %s\n", mapResult(flames[0]));
}
int main(){
char boy[200], girl[200];
printf("Enter Boy Name: ");
fgets(boy, sizeof(boy), stdin);
boy[strcspn(boy,"\n")]=0;
printf("Enter Girl Name: ");
fgets(girl, sizeof(girl), stdin);
girl[strcspn(girl,"\n")]=0;
printf("\nProcessing: ");
typePrint(boy, 30);
printf(" & ");
typePrint(girl, 30);
printf("\n\n");
cleanStr(boy);
cleanStr(girl);
int count = countRemaining(boy, girl);
if(count==0) count=1;
flamesAnimation(count);
return 0;
}