• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 21, comments - 2, trackbacks - 0, articles - 0

            POJ 2273 An Excel-lent Problem

            Posted on 2011-09-05 21:53 acpeng 閱讀(489) 評論(0)  編輯 收藏 引用 所屬分類: ACM程序

            把整數轉化為excel對應的列值http://poj.org/problem?id=2273
            Description

            A certain spreadsheet program labels the columns of a spreadsheet using letters. Column 1 is labeled as ``A", column 2 as ``B", ..., column 26 as ``Z". When the number of columns is greater than 26, another letter is used. For example, column 27 is ``AA", column 28 is ``AB" and column 52 is ``AZ". It follows that column 53 would be ``BA" and so on. Similarly, when column ``ZZ" is reached, the next column would be ``AAA", then ``AAB" and so on.

            The rows in the spreadsheet are labeled using the row number. Rows start at 1.

            The designation for a particular cell within the spreadsheet is created by combining the column label with the row label. For example, the upper-left most cell would be ``A1". The cell at column 55 row 23 would be ``BC23".

            You will write a program that converts numeric row and column values into the spreadsheet designation.

            Input

            Input consists of lines of the form: RnCm. n represents the row number [1,300000000] and m represents the column number, 1<=m<=300000000. The values n and m define a single cell on the spreadsheet. Input terminates with the line: R0C0 (that is, n and m are 0). There will be no leading zeroes or extra spaces in the input.

            Output

            For each line of input (except the terminating line), you will print out the spreadsheet designation for the specified cell as described above.

            Sample Input

            R1C1
            R3C1
            R1C3
            R299999999C26
            R52C52
            R53C17576
            R53C17602
            R0C0
            

            Sample Output

            A1
            A3
            C1
            Z299999999
            AZ52
            YYZ53
            YZZ53
            

            Source

            Greater New York 2004

            進制轉化問題,把列數改成26進制輸出,分別用A,B...Z代替1,2,3...這里base[0]='Z',表示n與26余數為0時的取值,但進位問題需要注意,分余數是否為0兩種情況分析。
            代碼:
            #include<stdio.h>
            #define R 26
            char base[30]="ZABCDEFGHIJKLMNOPQRSTUVWXYZ";
            void fun(int N)
            {
                
            int i=0,j; char str[10];
                
            while(N>R)
                
            {
                    str[i
            ++]=base[N%R];
                    N
            =N%R==0?N/R-1:N/R;
                }

                str[i]
            =base[N];
                
            for(j=i;j>=0;j--)
                    printf(
            "%c",str[j]);
            }

            int main()
            {
                
            int m,n;
                
            while(scanf("%*c%d%*c%d",&m,&n)!=EOF)
                
            {
                    getchar();
                    
            if(m==0 && n==0)break;
                    fun(n);
                    printf(
            "%d\n",m);
                }

                
            return 0;
            }

            久久精品aⅴ无码中文字字幕不卡 久久精品aⅴ无码中文字字幕重口 | 久久99热只有频精品8| 精品国产青草久久久久福利| 少妇无套内谢久久久久| 色婷婷综合久久久中文字幕| 色婷婷久久综合中文久久蜜桃av| 久久亚洲精品国产精品| 996久久国产精品线观看| 精品久久人人爽天天玩人人妻| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 久久人人超碰精品CAOPOREN| 亚洲国产成人乱码精品女人久久久不卡 | 久久精品国产清自在天天线 | 久久男人AV资源网站| 青青草原综合久久大伊人| 久久久久免费看成人影片| 久久婷婷久久一区二区三区| 一本一道久久a久久精品综合| 亚洲中文字幕无码久久2020| 91久久精品国产成人久久| 伊人久久大香线蕉综合5g| www.久久热.com| 97香蕉久久夜色精品国产| 久久精品国产精品国产精品污| 久久久这里有精品| 国产日韩久久久精品影院首页| 久久er99热精品一区二区| 日日狠狠久久偷偷色综合免费| 欧美久久精品一级c片片| 久久精品人人做人人爽电影| 久久久久久毛片免费看| 免费观看久久精彩视频| 国产成人精品久久| 久久丫忘忧草产品| 国产三级精品久久| 2021国产成人精品久久| 久久国产一区二区| 国产亚洲欧美精品久久久| 日韩精品无码久久久久久| 久久人人爽人人爽人人片av麻烦 | 久久精品国产亚洲AV不卡|