fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void toABC(int n, char *s){
  5. s[0] = '\0';
  6. int i=0;
  7. int k;
  8. char c;
  9. while(n>0){
  10. s[i] = 'A'-1 + n%27;
  11. n /= 27;
  12. ++i;
  13. }
  14. s[i] = '\0';
  15. for(k=0;k<i/2;++k){
  16. c = s[k]; s[k] = s[i-1-k]; s[i-1-k]=c;
  17. }
  18. }
  19. long long LaySo(char *str, char b, char e){
  20. long long n = 0;
  21. int i=0;
  22. while(str[i]!=b) ++i; //dich den chu
  23. ++i; //bo qua chu
  24. while(str[i]!=e){
  25. n += (str[i]-'0') + n*10;
  26. ++i;
  27. }
  28. return n;
  29. }
  30. int main(void) {
  31. // your code here
  32. char s[100];
  33. char c[10];
  34. long long hang;
  35. int cot;
  36. while(1){
  37. scanf("%s",s);
  38. if(strcmp(s,"R0C0")==0) break;
  39. hang = LaySo(s,'R','C');
  40. cot = (int)LaySo(s,'C','\0'); //0 = '\0'
  41. toABC(cot,c);
  42. printf("%s%lld\n",c,hang);
  43. }
  44. return 0;
  45. }
Success #stdin #stdout 0s 2164KB
stdin
R1C1
R3C1
R1C3
R299999999C26
R52C52
R53C17576
R53C17602
R0C0
stdout
A1
A3
C1
AA621640754
BC57
AFUV58
AFWH58