Loading...  太不容易了,从同学问我开始做到凌晨两点。 ``` #include <stdio.h> #include <string.h> #include <stdlib.h> #define isRC 1 #define isXy 0 char map[1000010][8] = {0}; // x,y should not be 0 inline void Xy2RyCx(const char *str, int *x, int *y) { int sum = 0; int i; for (i = 0; *(str + i) >= 'A'; i++) { if (*(str + i) >= 'A') { sum = sum * 26 + (*(str + i) - '@'); } } *x = sum; *y = atoi(str + i); } inline void RyCx2Xy(char *str, int *x, int *y) { int i = 1; for (i = 1; *(str + i) != 'C'; i++) ; *(str + i) = 0; *y = atoi(str + 1); *x = atoi(str + i + 1); } inline void init_map() { char str[8] = "@@@@@@@"; for (int i = 1; i <= 1000000; i++) { str[6] += 1; for (int j = 6; str[j] == 'Z' + 1; j--) { str[j - 1] += 1; str[j] = 'A'; } int k; for(k=0;str[k]=='@';k++); strcpy(map[i], str + k ); } } inline int judge(char *str) { if (*str != 'R' || *(str + 1) > '9') { return isXy; } for (int i = 2; i < strlen(str) - 1; i++) { if (*(str + i) == 'C') { return isRC; } } return isXy; } int main() { init_map(); int n; char str[100] = {0}; int x[100010]; int y[100010]; int z[100010] = {0}; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", str); z[i] = judge(str); if (z[i] == isXy) { Xy2RyCx(str, x + i, y + i); } else { RyCx2Xy(str, x + i, y + i); } } for (int i = 0; i < n; i++) { if (z[i] == isRC) { printf("%s", map[x[i]]); printf("%d\n", *(y + i)); } else { printf("R%dC%d\n", *(y + i), *(x + i)); } } return 0; } ``` 还是各种小问题不断,比如认为10^5后面只有四个零之类的。 **我是垃圾** 最后修改:2022 年 11 月 12 日 © 允许规范转载 赞 1 如果觉得我的文章对你有用,请随意赞赏