#include <string>
#include <iostream>
using namespace std;
class NumString
{
public:
NumString()
{
m_str = '0';
m_iLenght = 1;
}
~NumString()
{
}
public:
NumString& operator ++()
{
int len = this->m_iLenght;
char c = m_str[len - 1];
int n = c - '0';
bool flag = n > 8;
n = (++n) % 10;
this->m_str[len - 1] = '0' + n;
if(this->m_iLenght == 1 && flag)
{
this->m_str.insert(0, "1");
this->m_iLenght++;
}
for(int i = len - 2; i >= 0; i--)
{
char c = m_str[i];
int n = c - '0';
if(flag)
{
n++;
flag = n > 9;
n = n % 10;
this->m_str[i] = '0' + n;
if(i == 0 && flag)
{
this->m_str.insert(0, "1");
this->m_iLenght++;
break;
生成连续的不限长度的数字字符串
最新推荐文章于 2021-07-26 10:31:47 发布