Advertisement
nontawat1996

1059 SMS

Mar 4th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int start,m;
  6. int key();
  7. char kb[11][5]= {"","ABC","DEF","GHI","JKL","MNO","PQRS","TUV","WXYZ"};
  8. char out[85]= {'\0'};
  9. int main()
  10. {
  11. int n,i,h,v;
  12.  
  13. scanf("%d%d%d",&n,&start,&m);
  14. start-=1;
  15. key();
  16. for(i=0; i<n-1; i++)
  17. {
  18. scanf("%d%d%d",&h,&v,&m);
  19. start=start+h+(v*3);
  20. key();
  21. //printf("---%s---\n",out);
  22. }
  23. if(strlen(out)==0)
  24. {
  25. printf("null");
  26. return 0;
  27. }
  28. printf("%s",out);
  29. return 0;
  30. }
  31.  
  32. int key()
  33. {
  34. int len=strlen(out),i;
  35. if(start==0 && len>0)
  36. {
  37. for(i=len-1;i>=len-m;i--)
  38. {
  39. out[i]='\0';
  40. if(i<=0) break;
  41. }
  42. return 0;
  43. }
  44. if(start==6 || start==8)
  45. {
  46. m%=4;
  47. if(m==0) m=4;
  48. m--;
  49. out[len]=kb[start][m];
  50. }
  51. else
  52. {
  53. m%=3;
  54. if(m==0) m=3;
  55. m--;
  56. out[len]=kb[start][m];
  57. }
  58.  
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement