zoukankan      html  css  js  c++  java
  • ytu 1301:Excel地址转换(水题,进制转换)

    Excel地址转换

    Time Limit: 1 Sec  Memory Limit: 128 MB
    Submit: 41  Solved: 11
    [Submit][Status][Web Board]

    Description

        Excel是最常用的办公软件。每个单元格都有唯一的地址表示。比如:第12行第4列表示为:“D12”,第5行第255列表示为“IU5”。
        
        事实上,Excel提供了两种地址表示方法,还有一种表示法叫做RC格式地址。 第12行第4列表示为:“R12C4”,第5行第255列表示为“R5C255”。

        你的任务是:编写程序,实现从RC地址格式到常规地址格式的转换。

    Input

        用户先输入一个整数n(n<100),表示接下来有n行输入数据。

        接着输入的n行数据是RC格式的Excel单元格地址表示法。

    Output

     程序输出n行数据,每行是转换后的常规地址表示法。

    Sample Input

    3
    R1C1
    R65535C256
    R100C100
     
    3
    R100C99
    R1C255
    R255C27

    Sample Output

    A1
    IV65535
    CV100
     
    CU100
    IU1
    AA255

    HINT

    这是道好题,虽然也是水题,但是思路很有创意。

     1 #include <iostream>
     2 #include <stdio.h>
     3 using namespace std;
     4 
     5 int main()
     6 {
     7     int n;
     8     while(cin>>n){
     9         getchar();
    10         while(n--){
    11             char s[101];
    12             int r,c;
    13             scanf("R%dC%d",&r,&c);
    14             getchar();
    15             char C[101];
    16             int l=0;
    17             while(c/26){
    18                 int t;
    19                 t=c%26;
    20                 C[l++]='A'+t-1;
    21                 c=c/26;
    22             }
    23             C[l]='A'+c-1;
    24             for(;l>=0;l--)
    25                 cout<<C[l];
    26             cout<<r<<endl;
    27             //C[l+1]='';
    28             //cout<<C<<endl;
    29         }
    30         cout<<endl;
    31     }
    32     return 0;
    33 }

    Freecode : www.cnblogs.com/yym2013

  • 相关阅读:
    Bulls and Cows leetcode
    Binary Search Tree Iterator leetcode
    Binary Tree Paths leetcode
    Largest Number leetcode
    Reverse Words in a String leetcode
    Fraction to Recurring Decimal leetcode
    Compare Version Numbers leetcode
    [LeetCode] 1025. Divisor Game
    [LeetCode] 64. Minimum Path Sum
    [LeetCode] 62. Unique Paths
  • 原文地址:https://www.cnblogs.com/yym2013/p/3460333.html
Copyright © 2011-2022 走看看