-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloveCalculator.cpp
69 lines (52 loc) · 1.44 KB
/
loveCalculator.cpp
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
//C++
#include <iostream>
#include <string>
#include <algorithm>
int main(){
std::string name1, name2;
int pointT = 0, pointL = 0;
std::cout << "Enter the name of the first person : " ;
std::getline(std::cin,name1);
std::transform(name1.begin(), name1.end(), name1.begin(), ::tolower);
std::cout << "Enter the name of the second person : " ;
std::getline(std::cin,name2);
std::transform(name2.begin(), name2.end(), name2.begin(), ::tolower);
std::string tru = "true";
std::string love = "love";
for(char c : name1){
if(tru.find(c) != std::string::npos){
pointT++;
}
if(love.find(c) != std::string::npos){
pointL++;
}
}
for (char c :name2){
if(tru.find(c) != std::string::npos){
pointT++;
}
if(love.find(c) != std::string::npos){
pointL++;
}
}
std::cout << "The total love score is: " << pointT << pointL << std::endl;
return 0;
}
//PYTHON
name1 = input("Enter the name of the first person : ")
name2 = input("Enter the name of the second person : ")
tru = ["t","r","u","e"]
love = ["l","o","v","e"]
pointT = 0
pointL = 0
for char in name1:
if char in tru :
pointT += 1
if char in love :
pointL += 1
for char in name2:
if char in tru :
pointT += 1
if char in love :
pointL += 1
print(f"The total love is : {pointT}{pointL}")