CF1B Spreadsheets

思路:

进制转换。

scanf,sscanf正则输入http://blog.csdn.net/tujiaw/article/details/6139896

实现:

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 
 5 void g(int x)
 6 {
 7     if (x) g((x - 1) / 26), putchar('A' + (x - 1) % 26);
 8 }
 9 
10 char s[100];
11 int main()
12 {
13     int n, x, y;
14     scanf("%d%*c", &n);
15     while (n--)
16     {
17         gets(s);
18         if (sscanf(s, "%*c%d%*c%d", &x, &y) == 2)
19         {
20             g(y);
21             printf("%d
", x);
22         }
23         else
24         {
25             int p = 0;
26             int i = 0;
27             while (s[i] >= 'A' && s[i] <= 'Z') p = p * 26 + s[i] - 'A' + 1, i++;
28             printf("R%sC%d
", &s[i], p);
29         }
30     }
31     return 0;
32 }
原文地址:https://www.cnblogs.com/wangyiming/p/7158280.html