-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturn-keypad-string.cpp
More file actions
65 lines (64 loc) · 1.07 KB
/
return-keypad-string.cpp
File metadata and controls
65 lines (64 loc) · 1.07 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
#include<iostream>
#include<vector>
#include <string>
using namespace std;
string info[9];
void keypad(int num,vector<string> &p)
{
if(num==0)
{
p.push_back("");
return;
}
int m=num%10;
num=num/10;
keypad(num,p);
int len=info[m].length();
int len1=p.size();
int j=0;
for(int i=0;i<((len*len1)-len1);i++)
{
if(j>=len1)
{
j=0;
}
if(j>=0 && j<len1)
{
p.push_back(p.at(j));
j++;
}
}
int k=0,count=0;
for(int i=0;i<len*len1;i++)
{
if(count==p.size()/len)
{
k++;
count=0;
}
p[i]=p[i]+info[m][k];
count++;
}
}
int main()
{
info[0]="NULL";
info[1]="NULL";
info[2]="abc";
info[3]="def";
info[4]="ghi";
info[5]="jkl";
info[6]="mno";
info[7]="pqrs";
info[8]="tuv";
info[9]="wxyz";
int num;
cin>>num;
vector<string> p;
keypad(num,p);
for(int i=0;i<p.size();i++)
{
cout<<p[i]<<endl;
}
return 0;
}