immuntasir

UVA 10260

Feb 17th, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int convert(char c) {
  4.     if (c=='B' || c=='F' ||c=='P' || c=='Y') return 1;
  5.     if (c=='C'||c=='G'||c=='J'||c=='K'||c=='Q'||c=='S'||c=='X'||c=='Z') return 2;
  6.     if (c=='D'||c=='T') return 3;
  7.     if (c=='L') return 4;
  8.     if (c=='M' || c=='N') return 5;
  9.     if (c=='R') return 6;
  10.     else return 0;
  11. }
  12.  
  13. int main() {
  14.     char code[100];
  15.     while (scanf("%s",code)==1) {
  16.         int len = strlen(code);
  17.         int i=0,j=0;
  18.         for (;i<len;i++) {
  19.             int k = convert(code[i]);
  20.             if (k!=0 && k != j) {
  21.                 printf("%d",k);
  22.                 j=k;
  23.             }
  24.             else if (k==0) j=0;
  25.         }
  26.         printf("\n");
  27.     }
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment