-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mapping_matches.txt
59 lines (53 loc) · 934 Bytes
/
mapping_matches.txt
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
**** HACKERRANK MAPPING QUESTION ******
1) 1 to 9 then even odd
2)matching sticks
--------------------------------------------------
Input-
8
11
Output
eight
nine
even
odd
int main()
{
int a, b;
cin >> a;
cin >> b;
string num[9] = {"one", "two", "three", "four", "five", "six", "seven","eight", "nine"};
for(int i=a; i<=b;i++)
{
if(i<=9)
cout << num[i-1] << endl;
else
if(i%2==0)
cout << "even\n";
else
cout << "odd\n";
}
return 0;
}
-----------------------------------------
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int a,b,sum=0;
cin>>a>>b;
int c= a+b;
int map[10]={6,2,5,5,4,5,6,3,7,6};
while(c!=0)
{
int temp=c%10;
sum = map[temp]+sum;
c=c/10;
}
cout<<sum<<endl;
}
return 0;
}