Write a program that outputs the string representation of numbers from 1 to n.

But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”.

Example:

n = 15,

Return:
[
"1",
"2",
"Fizz",
"4",
"Buzz",
"Fizz",
"7",
"8",
"Fizz",
"Buzz",
"11",
"Fizz",
"13",
"14",
"FizzBuzz"
]

/**
 * Return an array of size *returnSize.
 * Note: The returned array must be malloced, assume caller calls free().
 */
int lenofnum(int n)
{
    int len = 0;
    while(n)
    {
        n /= 10;
        len += 1;
    }
    
    return len;
}
char** fizzBuzz(int n, int* returnSize) {
    *returnSize=n;
    char **s=(char **)malloc(n*sizeof(char *));//数组指针
    for(int i=1; i<=n; i++)
    {
        if(i%15==0)//15的倍数
        {
            s[i-1] = (int *)malloc(9 *sizeof(char));
            snprintf(s[i-1], 9 ,"%s", "FizzBuzz");
        }
        else if(i%3==0)//3的倍数
        {
            s[i-1] = (int *)malloc(5 *sizeof(char));
            snprintf(s[i-1], 5 ,"%s", "Fizz");
        }
        else if(i%5==0)//5的倍数
        {
            s[i-1] = (int *)malloc(5 *sizeof(char));
            snprintf(s[i-1], 5 ,"%s", "Buzz");
        }
        else//其他
        {
            s[i-1] = (int *)malloc((lenofnum(i) + 1) *sizeof(char));
            snprintf(s[i - 1],lenofnum(i) + 1 ,"%d", i);
        }
        
        
    }
    return s;
}