Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int convert(char c) {
- if (c=='B' || c=='F' ||c=='P' || c=='Y') return 1;
- if (c=='C'||c=='G'||c=='J'||c=='K'||c=='Q'||c=='S'||c=='X'||c=='Z') return 2;
- if (c=='D'||c=='T') return 3;
- if (c=='L') return 4;
- if (c=='M' || c=='N') return 5;
- if (c=='R') return 6;
- else return 0;
- }
- int main() {
- char code[100];
- while (scanf("%s",code)==1) {
- int len = strlen(code);
- int i=0,j=0;
- for (;i<len;i++) {
- int k = convert(code[i]);
- if (k!=0 && k != j) {
- printf("%d",k);
- j=k;
- }
- else if (k==0) j=0;
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment