stl(五)------生成 A-Z, AA - ZZ , AAA, -- ZZZ AAAA -- AAAZ 等序列的字符
来源:互联网 发布:虎头软件是什么 编辑:程序博客网 时间:2024/06/04 23:30
/*The Z -> AA, ZZ -> AAA, ZZZ -> AAAA transitions had me stuck for a while
(which seems to be a problem in the good Doctor's perl program),
but the following C++ code seems to work.It uses the fairly common idiom for printing base N values by constructing
the value from least to greatest significant digit in an array,
and then reversing it for presentation (in this case, returing it as a string).*/Code:#include <iostream>#include <string>#include <vector>#include <algorithm>#include <iterator>std::stringconv(unsigned long val){ static const char digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; std::vector<char> buf; buf.push_back(digits[val % 26]); val /= 26; if (val) { do { --val; buf.push_back(digits[val % 26]); val /= 26; } while (val); } // copy constructed value into string. // by iterating through the buffer in reverse order, the // resulting string will be in the correct order. std::string s; std::copy(buf.rbegin(), buf.rend(), std::back_inserter(s)); return s;}
0 0
- stl(五)------生成 A-Z, AA - ZZ , AAA, -- ZZZ AAAA -- AAAZ 等序列的字符
- java 实现生成excel表头,A-Z;AA-ZZ;AAA-ZZZ支持无限
- 求a+aa+aaa+aaaa+......+aaa......aa的值
- 求a+aa+aaa+aaaa+...的值
- 求a+aa+aaa+aaaa+....的值
- 求s=a+aa+aaa+aaaa+aa...a的值,输出:a+aa+aaa+aaaa+aa...a=s
- a+aa+aaa+aaaa+aaaaa
- S=a+aa+aaa+aaaa+aaaa................
- 已知一个序列seq=[a,b,....,z,aa,ab,...,zz,aaa,aab,....],求任意一个字符串s=[a-z]+在seq中出现的位置
- 求Sn= a+aa+aaa+aaaa+aaaaa的五项之和,求中a是一个数字
- a+aa+aaa+aaaa+……
- s=a+aa+aaa+aaaa.....
- 求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字
- 求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字
- 求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字
- 求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字
- 求s=a+aa+aaa+aaaa+aa...a的值
- 关于s=a+aa+aaa+aaaa+aa...a的程序实现
- 记一次ubuntu误操作导致无法用sudo
- cocos2d-x所有动画
- PAT basic 1010 : 一元多项式求导
- LeetCode 67 — Add Binary(C++ Java Python)
- 在centos上配置samba服务器
- stl(五)------生成 A-Z, AA - ZZ , AAA, -- ZZZ AAAA -- AAAZ 等序列的字符
- mysql备忘
- hadoop 2.2.0配置遇到的问题总结
- poj 2481 Cows(树状数组)题目有陷阱,转换后与stars类似
- android从init到开机动画启动关闭流程一简易图(surfaceflinger启动的位置)
- 怎样将整数转化成字符串数,并且不用函数itoa
- Activity的生命周期
- nginx和php-fpm配置
- What Is OA工作流