标签:dig code rgb tco lse pre div color one
int* plusOne(int* digits, int digitsSize, int* returnSize){
int i,carry=1;
int* arr = (int*)calloc(digitsSize+1,sizeof(int));
for (i=digitsSize-1; i>=0; i--)
{
if (digits[i] + carry < 10)
{
arr[i+1] = digits[i] + carry;
carry=0;
}
else arr[i+1] = 0;
}
*returnSize = digitsSize + carry;
arr[0] = 1;
return (carry)? arr : arr+1;
}
标签:dig code rgb tco lse pre div color one
原文地址:https://www.cnblogs.com/ganxiang/p/13656438.html