WA in Birthday CANDLES

I am not getting why my submission of Easy problem Birthday Candles is wrong. Please help. My code is pasted below.

#include<stdio.h>
#include<math.h>
int index(int *arr)
{
 int i;
 for(i=9;i>=1;i--)
     if(arr[i]==arr[0])
       return i;

 return 0;
}
int min1(int *arr)
{
  int min=arr[0],mini=0,i;
  for(i=1;i<10;i++)
    if(arr[i]<min)
    {min=arr[i];// printf("%d.",min);
     mini=i;}
  return mini;
}
int main()
{
  int arr[10],i,j,k,r,d,t,a=0;
  scanf("%d",&d);
  for(i=0;i<d;i++)
  {
    for(j=0;j<10;j++)
    {
      scanf("%d",&arr[j]);
    }
    k= min1(arr);
    a=0;
    //printf("%d\n",k);
    if(arr[k]==0&&k!=0)
      printf("%d\n",k);
    else if(arr[k]>0&& k!=0)
    {
       for(j=0;j<=arr[k];j++)
          a=a*10+k;
       printf("%d",a);
    }
    else
    {
       r=index(arr);
       if(r==0)
       {
         t=10*pow(10,arr[k]);
         printf("%d\n",t);
       }
       else
       {
          for(j=0;j<=arr[r];j++)
            a=a*10+r;
          printf("%d",a);
       }
    }
 }
return 0;
}