将十进制数字转换为类似于Excel标头的数字 [英] Convert decimal number to excel-header-like number

查看:91
本文介绍了将十进制数字转换为类似于Excel标头的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

0 = A
1 = B
...
25 = Z
26 = AA
27 = AB
...
701 = ZZ
702 = AAA

我想不出任何不涉及loop-bruteforce的解决方案:-(

I cannot think of any solution that does not involve loop-bruteforce :-(

我希望有一个函数/程序,该函数可以接受十进制数并返回一个字符串.

I expect a function/program, that accepts a decimal number and returns a string as a result.

推荐答案

Haskell, 78 57 50 43个字符

Haskell, 78 57 50 43 chars

o=map(['A'..'Z']:)$[]:o
e=(!!)$o>>=sequence

其他条目未计入驱动程序,驱动程序又增加了40个字符:

Other entries aren't counting the driver, which adds another 40 chars:

main=interact$unlines.map(e.read).lines

一种新的方法,它使用了一个无限的懒惰列表和Monads的强大功能!此外,使用sequence使我成为:),使用无限列表使我成为:o

A new approach, using a lazy, infinite list, and the power of Monads! And besides, using sequence makes me :), using infinite lists makes me :o

这篇关于将十进制数字转换为类似于Excel标头的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆