B. Spreadsheets
来源:互联网 发布:衣柜 知乎 编辑:程序博客网 时间:2024/04/30 21:18
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.
The first line of the input contains integer number n (1 ≤ n ≤ 105), the number of coordinates in the test. Then there follow nlines, 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 .
Write n lines, each line should contain a cell coordinates in the other numeration system.
2R23C55BC23
BC23R23C55
解题说明:此题就是实现两种表示类型的转换,主要是字符串处理问题
#include<cstdio>#include<iostream>#include<cstring>#include<cmath>using namespace std;char line[1024], t[1024], *p;int r, c;void printcol(int c) { if(!c) {return;} printcol((c - 1)/26); putchar(((c - 1)% 26) + 'A');}int main(){int n,i;scanf("%d",&n);for(i=0;i<n;i++){scanf("%s", line); if(sscanf(line,"R%dC%d", &r, &c) == 2) { printcol(c); printf("%d\n", r); } else { sscanf(line, "%[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;}
- B. Spreadsheets
- B. Spreadsheets
- B. Spreadsheets
- CODEFORCES:1B. Spreadsheets
- cf 1B. Spreadsheets
- Round #1 B. Spreadsheets
- CodeForces 1B Spreadsheets
- CodeForces - 1B Spreadsheets
- Codeforces 1B. Spreadsheets
- codeforces-1B. Spreadsheets
- cf # 1 B. Spreadsheets
- 1B. Spreadsheets
- CodeForces 1B Spreadsheets
- CodeForces#1B Spreadsheets
- 1B. Spreadsheets
- Codeforces #1 B. Spreadsheets
- 1B. Spreadsheets
- CodeForces 1B Spreadsheets
- 第五周项目三长方柱类
- Mindmanager2012安装图解
- 在任务管理器里用内存使用来画波浪线
- [Go] --- 指针和内存分配
- Windows下的双显的设置
- B. Spreadsheets
- 蓝桥杯 2013 全国软件设计大赛 模拟赛 Java 本科B组 解题报告
- Android开发之二:Android用户界面开发简介
- CSDN博客与ITEYE博客同步
- PCI Express 1x, 4x, 8x, 16x bus pinout
- delphi DateUtils功能详解
- 用secureCRT链接远程linux操作系统,出现“远程主机拒绝链接”的提示
- 【露】4.3写在清明小长假前
- COM引用计数兼浅谈JavaScript与ActiveX Web编程