Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- decode_string.c
- Task:
- https://www.facebook.com/dmilicev/posts/4081967018490924:53
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- #include <string.h>
- int main(void)
- {
- int i=0;
- char str[]= "TR.XX";
- printf("\n%s\n\n",str);
- while( str[i] ) // for all characters of coded string
- {
- switch( str[i] ) // use switch-case to display proper values
- {
- case 'X' :
- printf("%d",0);
- break;
- case 'C' :
- printf("%d",1);
- break;
- case 'O' :
- printf("%d",2);
- break;
- case 'M' :
- printf("%d",3);
- break;
- case 'P' :
- printf("%d",4);
- break;
- case 'U' :
- printf("%d",5);
- break;
- case 'T' :
- printf("%d",6);
- break;
- case 'E' :
- printf("%d",7);
- break;
- case 'R' :
- printf("%d",8);
- break;
- case 'S' :
- printf("%d",9);
- break;
- default : // in default, display same value.
- printf("%c",str[i]);
- break;
- } // switch()
- i++;
- } // while()
- printf("\n");
- return 0;
- } // main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement