#include <stdlib.h>
#include<math.h>
int* decode(int* encoded, int encodedSize, int first, int* returnSize)
{
int i = 1;
int count = encodedSize + 1;
int* ret = returnSize;
returnSize[0]= first;
// returnSize++;
while (i<count)
{
returnSize[i] = abs((returnSize[i-1] - encoded[i-1]));
i++;
}
return ret;
}
int main()
{
int encoded[] = { 1, 2, 3 };
int first = 1;
int encodedSize = sizeof(encoded) / sizeof(encoded[0]);
int count = encodedSize + 1;
int * returnSize = (int *)malloc(sizeof(char) * (count));
returnSize=decode(encoded, encodedSize, first, returnSize);
if (returnSize == NULL)
{
exit(0);
}
for(int i = 0; i < count; i++)
printf("%d ", returnSize[i]);
free(returnSize);
return 0;
}