Advertisement
rdsedmundo

...

Jun 7th, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. prog.c - id=11720103 - time::1402157189433 - WRONG ANSWER
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int main(){
  6.     char c =' ';
  7.     while(c!='\n'){
  8.         scanf("%c",&c);
  9.        
  10.         if(c=='A' || c=='B' || c=='C')
  11.             c='2';
  12.         else if(c=='D' || c=='E' || c=='F')
  13.             c='3';
  14.         else if(c=='G' || c=='H' || c=='I')
  15.             c='4';
  16.         else if(c=='J' || c=='K' || c=='L')
  17.             c='5';
  18.         else if(c=='M' || c=='N' || c=='O')
  19.             c='6';
  20.         else if(c=='p' || c=='Q' || c=='R' || c=='S')
  21.             c='7';
  22.         else if(c=='T' || c=='U' || c=='V')
  23.             c='8';
  24.         else if(c=='X' || c=='W' || c=='Y' || c=='Z')
  25.             c='9';
  26.        
  27.         printf("%c",c);
  28.     }
  29.     return 0;      
  30. } /* */
  31.  
  32. prog.c - id=11720152 - time::1402157249841 - ACCEPTED
  33. #include <stdio.h>
  34. #include <ctype.h>
  35.  
  36. int main() {
  37.     char ch;
  38.     int dig;
  39.     while ((ch = getc(stdin)) != EOF) {
  40.         if (isalpha(ch)) {
  41.             if (ch >= 'Q') {
  42.                 ch--;
  43.             }
  44.             dig = (ch - 'A') / 3;
  45.             putc('2' + dig, stdout);
  46.         } else {
  47.             putc(ch, stdout);
  48.         }
  49.     }
  50.     return 0;
  51. } /* */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement