#include <stdio.h> #include <string.h> #define M 1*10^6+10 char str[M]; /* 十进制变为二十六进制 */ void solve_10_to_26(char str[]) { char re[M]; int p = M - 1; int r, c; sscanf(str, "R%dC%d", &r, &c); re[p--] = 0; while(r) { re[p--] = r % 10 + '0'; r = r/10; } while(c) { re[p--] = (c-1) % 26 + 'A'; c = (c-1)/26; } printf("%s ", &re[p+1]); } /* 二十六进制变为十进制 */ void solve_26_to_10( char str[] ) { char cc[M]; int c = 0; int r; sscanf( str, "%[A-Z]%d", &cc, &r ); int len = strlen(cc); int p = 0; while(p < len) { c = c + cc[p++] - 'A' + 1; c = c * 26; } c = c / 26; printf("R%dC%d ", r, c); } int main() { int n; scanf("%d", &n); while(n--) { scanf("%s", &str); int a, b; if ( sscanf(str, "R%dC%d", &a, &b ) == 2) solve_10_to_26(str); else solve_26_to_10(str); } return 0; }