Plus One
问题:数组模拟整数加1
class Solution { public: vector<int> plusOne(vector<int> &digits) { int i,k=0; int a[100]; for(i=digits.size()-1;i>=0;i--) a[k++]=digits[i]; int c=1; for(i=0;i<k;i++) { int sum=a[i]+c; a[i]=sum%10; c=sum/10; } if(c!=0) a[k++]=c; vector<int> vec; for(i=k-1;i>=0;i--) vec.push_back(a[i]); return vec; } };