DECODE THE CODE
# include "conio,h"
# include "stdio.h"
#include "string.h"
char* decodeCode(char* encodedString)
{
char* decodedString = "",temp[10],s[100];
int i=0,j=0,k=0,len;
decodedString=s;
while(*(encodedString+i)!='\0')
{
if(*(encodedString+i)!=*(encodedString+i+1))
{
temp[j++]=*(encodedString+i);
temp[j]='\0';
len=0;
while(temp[len]!='\0')
{
len++;
}
switch(temp[0])
{
case '2':switch(len)
{
case 1:*(decodedString+k)='a';
break;
case 2:*(decodedString+k)='b';
break;
case 3:*(decodedString+k)='c';
break;
case 4:*(decodedString+k)='2';
break;
}
k++;
break;
case '3':switch(len)
{
case 1:*(decodedString+k)='d';
break;
case 2:*(decodedString+k)='e';
break;
case 3:*(decodedString+k)='f';
break;
case 4:*(decodedString+k)='3';
break;
}
k++;
break;
case '4':switch(len)
{
case 1:*(decodedString+k)='g';
break;
case 2:*(decodedString+k)='h';
break;
case 3:*(decodedString+k)='i';
break;
case 4:*(decodedString+k)='2';
break;
}
k++;
break;
case '5':switch(len)
{
case 1:*(decodedString+k)='j';
break;
case 2:*(decodedString+k)='k';
break;
case 3:*(decodedString+k)='l';
break;
case 4:*(decodedString+k)='5';
break;
}
k++;
break;
case '6':switch(len)
{
case 1:*(decodedString+k)='m';
break;
case 2:*(decodedString+k)='n';
break;
case 3:*(decodedString+k)='o';
break;
case 4:*(decodedString+k)='6';
break;
}
k++;
break;
case '7':switch(len)
{
case 1:*(decodedString+k)='p';
break;
case 2:*(decodedString+k)='q';
break;
case 3:*(decodedString+k)='r';
break;
case 4:*(decodedString+k)='s';
break;
case 5:*(decodedString+k)='7';
break;
}
k++;
break;
case '8':switch(len)
{
case 1:*(decodedString+k)='t';
break;
case 2:*(decodedString+k)='u';
break;
case 3:*(decodedString+k)='v';
break;
case 4:*(decodedString+k)='8';
break;
}
k++;
break;
case '9':switch(len)
{
case 1:*(decodedString+k)='w';
break;
case 2:*(decodedString+k)='x';
break;
case 3:*(decodedString+k)='y';
break;
case 4:*(decodedString+k)='z';
break;
}
k++;
break;
case '0':switch(len)
{
case 1:*(decodedString+k)=' ';
break;
}
k++;
break;
case '#':break;
default: return "\" \"";
}
j=0;
}
else
temp[j++]=*(encodedString+i);
i++;
}
decodedString[k]='\0';
return decodedString;
}
int main()
{
char input[200],*output;
printf("Enter string: ");
gets(input);
output=(char *)malloc(100);
output=decodeCode(input);
puts(output);
return 0;
}
5 comments:
gud
hey thnxxx for this
Please upload sparse addition
gr8
gud
Post a Comment