Language: C++

#include<stdio.h>
#include<stdlib.h>

#define n 100000
/*
int calculate(int a,int p,int counter){

    int i,j;
    int six_tmp = 0;
    int nine_tmp = 0;

    int six_num = pow(6,p);
    int nine_num = pow(9,p);

    if(a -  six_num == 0){
        return counter;
    }else if(a - nine_num == 0){
        return counter;
    }else if(a < six_num){
        return 99999;
    }else{
        for(i = 0;i < n;i++){
            six_tmp = calculate(a - six_num,i,counter+1);
            nine_tmp = calculate(a - nine_num,i,counter+1);

            if(six_tmp != 99999 && nine_tmp != 99999)
                return (six_tmp > nine_tmp)?nine_tmp:six_tmp;
            else if(six_tmp == 99999 && nine_tmp != 99999)
                return nine_tmp;
            else if(six_tmp != 99999 && nine_tmp == 99999)
                return six_tmp;

        }
       // printf("current value: %d %d\n",six_tmp,nine_tmp);
        return 99999;
    }

}
*/

void change(int dat,int ch[],int coin_value[],int vaild_coin)
{

    int i,j,tmp;
    int min = 99999;
    for(j = 0; j < vaild_coin; j++)
    {
        if(dat >= coin_value[j]){
            tmp = ch[dat - coin_value[j]] + 1;
        }else tmp = 99999;

        if(min > tmp)//算硬幣數量
                min  = tmp;
    }
    ch[dat] = min;
}

int main()
{

    int i,j,k;
    int dat,six,nine;
    int *coin_value;
    int *ch;

    ch = malloc(n*sizeof(int));//錢
    for(i = 0;; i++) //製造錢幣
        if(pow(6,i) > n)
        {
            six = i;
            break;
        }

    for(i = 0;; i++) //製造錢幣
        if(pow(9,i) > n)
        {
            nine = i;
            break;
        }

    //printf("%d %d",six,nine);
    coin_value = malloc((six+nine)*sizeof(int));

    int total = six + nine;
    for(i = 1,j = 0,k = 0;; k++)
    {
        int tmps = pow(6,i);
        int tmpn = pow(9,j);
        if(tmps > tmpn) //6 > 9
        {
            if(tmpn < n) //9 < 100000 排序
            {
                coin_value[k] = tmpn;
                j++;
            }
        }
        else if(tmps < n)
        {
            if(tmps < n)
            {
                coin_value[k] = tmps;
                i++;
            }
        }
        else break;
    }

    int vaild_coin = total - 3;
 /*
    for(i = 0; i < total - 3; i++)
        printf("%d ",coin_value[i]);
*/
    for(i = 0; i <= n; i++)
    {

        if(i == 0)
        {
            ch[i] = 0;
        }
        else
        {
            change(i,ch,coin_value,vaild_coin);
        }
    }
    /*
    printf("\n");
    for(i = 0;i < 100;i++)
        printf("%d\n",ch[i]);
*/
    //freopen("testdata2.in","r",stdin);

    while(scanf("%d",&dat) != EOF){
        printf("%d\n",ch[dat]);
    }

    free(coin_value);
    free(ch);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:16: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   66 |     ch = malloc(n*sizeof(int));//錢
      |          ~~~~~~^~~~~~~~~~~~~~~
      |                |
      |                void*
a.cc:68:12: error: 'pow' was not declared in this scope
   68 |         if(pow(6,i) > n)
      |            ^~~
a.cc:75:12: error: 'pow' was not declared in this scope
   75 |         if(pow(9,i) > n)
      |            ^~~
a.cc:82:24: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   82 |     coin_value = malloc((six+nine)*sizeof(int));
      |                  ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
      |                        |
      |                        void*
a.cc:87:20: error: 'pow' was not declared in this scope
   87 |         int tmps = pow(6,i);
      |                    ^~~