Created
August 25, 2014 18:53
-
-
Save vinay13/b7d422de3cbc9db16ecf to your computer and use it in GitHub Desktop.
keypadChar to no
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//hashmap phone keypad | |
#include <stdio.h> | |
#include <string.h> | |
int main() | |
{ | |
char str[]="facebook"; | |
const char hash[10][4]={"","","abc","def","ghi","jkl","mno","pqr","stu","vxz"}; | |
int i; | |
for(i=0;i<strlen(str);i++) | |
{ | |
int k=0; | |
int j=0; | |
if(str[i]==hash[j][k]) | |
{ | |
printf("%d",j); | |
j=0; | |
continue; | |
} | |
else | |
{ | |
while(str[i]!=hash[j][k]) | |
{ | |
k++; | |
if(k==4 || str[i]=='\0' ) | |
{ | |
j++; | |
k=0; | |
//break; | |
} | |
else | |
continue; | |
} | |
printf("%d",j); | |
} | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment