A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

TheLess

初级黑马

  • 黑马币:

  • 帖子:

  • 精华:

© TheLess 初级黑马   /  2015-11-27 20:43  /  615 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

1 - A 2 - B ….. 26 - Z 27 - AA 52 - AZ 53 - BA 54 - BB …. 702 - ZZ … 8888888888-ABTCNCWV 输入左边数字就输出右边对应字母; */ NSMutableArray *arr = [[NSMutableArray alloc] init];    while(n){        int mod = n % 26;        if(mod == 0){            mod=26;            n--;        };        [arr insertObject:[NSString stringWithFormat:@"%c",'A'-1+mod] atIndex:0];        n = n / 26;    }    NSLog(@"%@",[arr componentsJoinedByString:@""]);

1 个回复

倒序浏览
NSMutableArray *arr = [[NSMutableArray alloc] init];
    while(n){
        int mod = n % 26;
        if(mod == 0){
            mod=26;
            n--;
        };
        [arr insertObject:[NSString stringWithFormat:@"%c",'A'-1+mod] atIndex:0];
        n = n / 26;
    }
    NSLog(@"%@",[arr componentsJoinedByString:@""]);

为什么不自动排版
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马