#include<iostream>
#include<vector>
using namespace std;
struct c
{
vector<int> x;
void clear()
{
for(int i=0;i<x.size();i++)
{
x[i]=0;
}
}
void plus(long long a)
{
int cnt=0;
long long b=a;
while(a!=0)
{
cnt++;
a/=1000000000;
}
a=b;
if(cnt>x.size())
{
int xsize=cnt-x.size();
for(int w=1;w<=xsize;w++)
{
int xxx=0;
x.push_back(xxx);
for(int j=1;j<=x.size();j++)
{
swap(x[j-1],x[j]);
}
}
}
int i=x.size()-1;
while(a>0)
{
cout<<x[i]<<" "<<a%1000000000<<" ";
if(a%1000000000+x[i]>=1000000000)
{
a-=1000000000;
if(i+1==x.size())
{
x.push_back(0);
for(int j=0;j<x.size()-1;j++)
{
swap(x[j],x[j+1]);
}
x[i+1]+=1;
a-=1000000000;
}
else
{
x[i+1]+=1;
a-=1000000000;
}
}
x[i]+=a%1000000000;
a/=1000000000;
cout<<" "<<x[i]<<" "<<endl;
i--;
}
}
}a;
int main()
{
a.clear();
a.plus(9234567891);
//a.plus(9000000000);//a=18234567891
return 0;
}
想做到类似有效位的数据存放,可是最高位似乎并没有初始化,有谁知道吗?求!