Given a positive integer, return its corresponding column title as appear in an Excel sheet.

     -> A
     -> B
     -> C
    ...
     -> Z
     -> AA
     -> AB 

分析:

类比10进制数,此问题可简化为26进制数的问题(0-25)。

char* convertToTitle(int n) {
    int tmp = n;
    ;
    char *str = NULL;

    ) {
        i++;
        tmp = (tmp-)/;
    }

    str = (char *) malloc(i*sizeof(char));
    tmp = n;

    ; i--) {
        str[i-] = (tmp-)%+'A';
        tmp =(tmp-)/;
    }

    return str;
}

LeetCode 168. Excel Sheet Column Title的更多相关文章

  1. [LeetCode] 168. Excel Sheet Column Title 求Excel表列名称

    Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...

  2. leetcode 168. Excel Sheet Column Title 171 Excel Sheet Column Number

    题目 //像10进制一样进行 转换   只是要从0开始记录 class Solution { public: string convertToTitle(int n) { char a; string ...

  3. LeetCode 168. Excel Sheet Column Title (Excel 表格列名称)

    Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...

  4. ✡ leetcode 168. Excel Sheet Column Title 26进制数字 --------- java

    Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...

  5. Java for LeetCode 168 Excel Sheet Column Title

    Given a positive integer, return its corresponding column title as appear in an Excel sheet. For exa ...

  6. Java [Leetcode 168]Excel Sheet Column Title

    题目描述: Given a positive integer, return its corresponding column title as appear in an Excel sheet. F ...

  7. LeetCode 168 Excel Sheet Column Title(Excel的列向表标题)

    翻译 给定一个正整数,返回它作为出如今Excel表中的正确列向标题. 比如: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 - ...

  8. Leetcode 168 Excel Sheet Column Title 进制数转化

    题意:将数字转化成excel表中的行中的项目 本质是10进制转化为26进制,但是在中间加入了一个不一样的操作,在每次操作前都需要n-- class Solution { public: string ...

  9. [leetcode]168. Excel Sheet Column Title表格列名编码(十进制和多进制相互转换)

    其实就是一道,十进制转多进制的题 十进制转多进制就是从后边一位一位地取数. 这种题的做法是,每次用n%进制,相当于留下了最后一位,然后把这位添加到结果最前边.结果需要转为进制的符号. 下一次循环的n变 ...

随机推荐

  1. [ADB]ADB(Android Debug Bridge)简介及基础(不包含命令)

    "Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an ...

  2. 不就ideas嘛,谁没有!

    20160214 survey of current RDF triple storage systems survey of semantic web stack inference mechani ...

  3. Matlab中fread函数的高级使用方法及其帮助文档中容易引起歧义的地方

    参考资料:http://cn.mathworks.com/help/matlab/ref/fread.html 注意:参考资料针对的Matlab版本号R2015a,我使用的是R2013b. Matla ...

  4. iOS 动态下载系统提供的中文字体

    使用系统提供的中文字体,既可避免版权问题,又可以减小应用体积 #pragma mark - 判断字体是否已经被下载 - (BOOL)isFontDownLoaded:(NSString *)fontN ...

  5. Android常用库

    原文链接:http://www.jianshu.com/p/19368c2cdcaf 系统框架 1. 网络请求 Android Async HTTP Android异步HTTP库 AndroidAsy ...

  6. JavaScript变量作用域

    全部变量拥有全局作用域,局部变量拥有局部作用域(这里注意函数的参数也是局部变量) 1.在函数体内,局部变量的优先级高于同名的全局变量. 我的理解就是当你同时定义了同名的局部变量和全局变量时,函数体内返 ...

  7. [SimHash] find the percentage of similarity between two given data

    SimHash algorithm, introduced by Charikarand is patented by Google. Simhash 5 steps: Tokenize, Hash, ...

  8. NIO NIO.2

    An NIO.2 primer, Part 1: The asynchronous channel APIs http://blog.arganzheng.me/posts/java-network- ...

  9. Perforce P4V,添加映射

  10. ASP.NET MVC获取微信返回的json数据分页

    View @model JiaYe.WeiXin.Models.ViewModels.UserViewModel <div class="pull-left pagination&qu ...