题意翻译

人们常用的电子表格软件(比如: Excel)采用如下所述的坐标系统:

第一列被标为A,第二列为B,以此类推,第26列为Z。接下来为由两个字母构成的列号: 第27列为AA,第28列为AB...在标为ZZ的列之后则由三个字母构成列号,如此类推。

行号为从1开始的整数。

单元格的坐标由列号和行号连接而成。比如,BC23表示位于第55列23行的单元格。

有时也会采用被称为RXCY的坐标系统,其中X与Y为整数,坐标(X,Y)直接描述了对应单元格的位置。比如,R23C55即为前面所述的单元格。

您的任务是编写一个程序,将所给的单元格坐标转换为另一种坐标系统下面的形式。

输入

第一行一个整数n(1<=n<=10^5),表示将会输入的坐标的数量。

接下来n行,每行一个坐标。

注意: 每个坐标都是正确的。此外不会出现行号或列号大于10^6的单元格。

输出

n行,每行一个被转换的坐标。

输入格式:

2

R23C55

BC23

输出格式:

BC23

R23C55

分析:这道题其实挺简单的,想到就是将十进制的数转换为二十六进制就可以了,然后注意一下当n2%26==0的时候是'A'就可以了

 #include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
using namespace std;
char a[]; void solve1(){
int len=strlen(a);
int i;
int n1=,n2=;
int flag=;
for( i=; i<len; i++ ){
if(a[i]>=''&&a[i]<=''&&flag==){
n1=n1*+(a[i]-'');
}
else if(a[i]>=''&&a[i]<=''&&flag==){
n2=n2*+(a[i]-'');
}
else{
flag=;
}
}
// cout<<"n1="<<n1<<" n2="<<n2<<endl;
char temp[];
int pos=;
while(n2!=){
int t=n2%;
if(t==) temp[pos++]='A';
else{
temp[pos++]=(char)(+t-);
}
n2/=;
}
for( int i=pos-; i>=; i-- ){
cout<<temp[i];
}
cout<<n1<<endl;
} void solve2(){
// cout<<a<<endl;
int len=strlen(a);
int t=;
for( int i=; i<len; i++ ){
if(!(a[i]>='A'&&a[i]<='Z')){
t=i-;
break;
}
}
double m2=;
for( int i=; i<=t; i++ ){
m2=m2+(a[i]-'A'+)*(pow(,(t-i)));
// cout<<"a[i]-'A'+1="<<a[i]-'A'+1<<" "<<pow(26,(t-i))<<endl;
// cout<<"m2="<<m2<<endl;
}
cout<<'R';
for( int i=t+; i<len; i++ ){
cout<<a[i];
}
cout<<'C'<<m2<<endl;
} int main(){
int n;
cin>>n;
while(n--){
cin>>a;
if(a[]=='R'&&a[]>=''&&a[]<=''){
// cout<<a<<endl;
solve1();
}
else{
solve2();
}
}
return ;
}

但是在做这道题的时候有个很气愤的事,如果你把52行的double m2=0;改成int m2=0;(笔者实在codeblocks,,,MINGW编译器下跑的程序),会发现结果是不对的,样例二得出结果是m2=51

这个去看了下pow函数的源码,。。。。问了下大佬们,pow是很玄学的东西,所以大家在写东西的时候尽量避开pow函数,自己写个for循环鸭,也不长。。。

CF1B Spreadsheets的更多相关文章

  1. CF1B.Spreadsheets(电子表格) 题解 模拟

    作者:zifeiy 标签:模拟 题目出处:Spreadsheets 题目描述 在流行的电子表格系统中(例如,在Excel中),使用如下计算方式来对列号进行计算. 第1列对应A,第2列对应B,--,第2 ...

  2. cf------(round)#1 B. Spreadsheets(模拟)

    B. Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard inp ...

  3. CF Spreadsheets (数学)

    Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard input ...

  4. Spreadsheets

    很水的一道题,提醒自己要认真,做的头都快晕了.考虑26的特殊情况. D - Spreadsheets Time Limit:10000MS     Memory Limit:65536KB     6 ...

  5. codeforces 1B Spreadsheets

    In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is u ...

  6. Codeforces Beta Round #1 B. Spreadsheets 模拟

    B. Spreadsheets 题目连接: http://www.codeforces.com/contest/1/problem/B Description In the popular sprea ...

  7. B. Spreadsheets(进制转换,数学)

    B. Spreadsheets time limit per test 10 seconds memory limit per test 64 megabytes input standard inp ...

  8. C#-使用GoogleAPI读写spreadsheets

    https://docs.google.com/spreadsheets/在线使用一些常用办公工具,比如excel. 如需要C#代码自动读写这些excel,则需要使用GoogleAPI. 封装的公用类 ...

  9. 【题解】codeforces 1B Spreadsheets

    题意翻译 人们常用的电子表格软件(比如: Excel)采用如下所述的坐标系统:第一列被标为A,第二列为B,以此类推,第26列为Z.接下来为由两个字母构成的列号: 第27列为AA,第28列为AB-在标为 ...

随机推荐

  1. mysql批量修改列名为小写

    --  bo_project_info 为表名 SELECT concat( 'alter table ', 'bo_project_info', ' change column ', COLUMN_ ...

  2. echarts-环形图处理图列中的点击,使百分比的数据列不发生变化,默认追加其他选项

    将下列代码copy的echarts编辑器中 app.title = '环形图'; var $legendData = ['直接访问','邮件营销','联盟广告','视频广告','搜索引擎']; var ...

  3. Tone Mapping算法系列二:一种自适应对数映射的高对比度图像显示技术及其速度优化。

    办公室今天停电,幸好本本还有电,同事们好多都去打麻将去了,话说麻将这东西玩起来也还是有味的,不过我感觉我是输了不舒服,赢了替输的人不舒服,所以干脆拜别麻坛四五年了,在办公室一个人整理下好久前的一片论文 ...

  4. Substr与mb_substr区别

      <?php $str = substr('helloword',3,4);//从下标3开始截取截取4个字符 $str = substr('helloword',3);//从截取掉前三个字符 ...

  5. Vue $emit()不触发方法的原因

    vue使用$emit时,父组件无法触发监听事件的原因是: $emit传入的事件名称只能使用小写,不能使用大写的驼峰规则命名

  6. Effective Java 第三版——67. 明智谨慎地进行优化

    Tips 书中的源代码地址:https://github.com/jbloch/effective-java-3e-source-code 注意,书中的有些代码里方法是基于Java 9 API中的,所 ...

  7. [rook] rook的控制流

    以下是rook为一个pod准备可用块存储的过程: 1. rook operator运行,并且在k8s每台机器上运行一个rook agent的pod: 2. 用户创建一个pvc,并指定storagecl ...

  8. 10款WordPress的插件让你的网站的移动体验

    随着科技的不断发展,需要改变营销策略的一个企业就变得非常重要.你不能指望用你的营销工具来留住你的客户.智能手机和平板电脑已经改变了消费者的行为方式.现在,人们甚至不想去他们的电脑或笔记本电脑,以检查产 ...

  9. 基于expressjs老项目的翻新方案

    刚开始接触这方面的项目时,对ES规范理解不深,查了一些资料,发现如果不改expressjs的代码,大概率是没法用到最新的async/await了,后续也就没有继续往这个方面想. 这两天突然想起这个问题 ...

  10. perl控制流介绍(if条件,while,for循环,foreach)

    1. 语句块:{ }之间的部分即为BLOCK语句块. 2. 条件语句:if ( expression )  BLOCK; if ( expression )     BLOCK1else BLOCK2 ...