Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string>
- #include<bits/stdc++.h>
- using namespace std;
- char kp[][10] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
- string searchIn [] = {
- "prateek", "sneha", "deepak", "arnav", "shikha", "palak",
- "utkarsh", "divyam", "vidhi", "sparsh", "akku"
- };
- void printKeypadString(char *in, char *out, int i, int j)
- {
- if(in[i] == '\0')
- {
- out[j] = '\0';
- //converting char array to string
- int i;
- string s = "";
- for (i = 0; i < out[i] != '\0'; i++)
- s = s + out[i];
- //finding if the string is present as a substring
- for( i = 10; i >= 0; i--)
- {
- // *****************here I am getting no output why????????
- size_t found = searchIn[i].find(s);
- if (found != string::npos) {
- cout << searchIn[i]<<endl;
- }
- }
- return;
- }
- int digit = in[i] - '0';
- // cout<<digit<<endl;
- for(int k = 0; kp[digit][k] != '\0'; k++){
- // cout<<kp[digit][k]<<endl;
- out[j] = kp[digit][k];
- printKeypadString(in, out, i+1, j+1);
- }
- return;
- }
- int main() {
- char a[10], b[10];
- cin>>a;
- printKeypadString(a, b, 0, 0);
- return 0;
- }
Add Comment
Please, Sign In to add comment