immuntasir

UVA 10921

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