Codeforces 1B. Spreadsheets
来源:互联网 发布:aim聊天软件 编辑:程序博客网 时间:2024/06/06 00:18
Codeforces 1B. Spreadsheets
题目
B. Spreadsheets
In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 — AB, column 52 is marked by AZ. After ZZ there follow three-letter numbers, etc.
The rows are marked by integer numbers starting with 1. The cell name is the concatenation of the column and the row numbers. For example, BC23 is the name for the cell that is in column 55, row 23.
Sometimes another numeration system is used: RXCY, where X and Y are integer numbers, showing the column and the row numbers respectfully. For instance, R23C55 is the cell from the previous example.
Your task is to write a program that reads the given sequence of cell coordinates and produce each item written according to the rules of another numeration system.
Input
The first line of the input contains integer number n (1 ≤ n ≤ 105), the number of coordinates in the test. Then there follow n lines, each of them contains coordinates. All the coordinates are correct, there are no cells with the column and/or the row numbers larger than 106 .
Output
Write n lines, each line should contain a cell coordinates in the other numeration system.
Examples
input
2R23C55BC23
output
BC23R23C55
题目大意
给出一个字符串为字母串(表示列)+数字串(表示行)或R+数字串(表示列)+C+数字串(表示行),将给出的字符串转换成另一种类型
题解
字符串操作+模拟
(C++字符串操作不会……看了半天的资料……QAQ)
(关于sscanf操作的链接:https://baike.baidu.com/item/sscanf/10551550?fr=aladdin)
代码
#include<cstdio>using namespace std;char s[10005],t[10005],*p;int n,r,c;void work(int c) { if (c) work((c-1)/26),putchar((c-1)%26+'A');}int main(){ scanf("%d",&n); while (n--) { scanf("%s",s); if (sscanf(s,"R%dC%d",&r,&c)==2) work(c),printf("%d\n",r); else { sscanf(s,"%[A-Z]%d",t,&r); for (p=t,c=0;*p;p++) c=c*26,c+=*p-'A'+1; printf("R%dC%d\n",r,c); } } return 0;}
- CODEFORCES:1B. Spreadsheets
- CodeForces 1B Spreadsheets
- CodeForces - 1B Spreadsheets
- Codeforces 1B. Spreadsheets
- codeforces-1B. Spreadsheets
- CodeForces 1B Spreadsheets
- CodeForces#1B Spreadsheets
- Codeforces #1 B. Spreadsheets
- CodeForces 1B Spreadsheets
- codeforces 1B Spreadsheets
- Codeforces 1B Spreadsheets
- Codeforces 1B. Spreadsheets
- Codeforces Round #1B Spreadsheets
- Codeforces Beta Round #1 B. Spreadsheets
- CodeForces 1B. Spreadsheets(模拟)
- Codeforces Beta Round #1 B Spreadsheets
- CodeForces 1B Spreadsheets(EXCEL)
- CodeForces 1B Spreadsheets(模拟)
- 循环,数组,参数变量
- HDU1556 Color the ball
- java实现线性表中的链式存储
- c++————学习记录(一)
- chaofn python中List添加、删除元素的几种方法
- Codeforces 1B. Spreadsheets
- 判断栈的压入、弹出序列
- C语言 求最大公约数的三种方法,利用最大公约数求最小公倍数,通过分解质因数法来验证
- Maven环境搭建及5分钟体验
- UESTC-1073-秋实大哥与线段树
- Servlet学习笔记 同时上传多个文件的方法
- 10月7日C++学习笔记
- 重载overload与重写override的区别
- 工程管理器make和调试工具gdb