Can someone please tell me what is wrong with this code? It works fine for all the test cases in the example shown..Thanks in advance
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int t,a[10],min,k,j,val;
cin>>t;
while(t)
{
for(int i=0;i<10;i++)
cin>>a[i];
min=a[0];
k=0;
for(j=1;j<10;j++)
{
if(a[j]<min)
{ min=a[j];
k=j;
}
}
if(min!=0)
val=(k*pow(10,min))+k;
else
val=(k*pow(10,min));
if(val==0)
{
min=a[1];
k=1;
for(j=2;j<10;j++)
{
if(a[j]<min)
{ min=a[j];
k=j;
}
}
val=k*pow(10,min);
}
cout<<val<<endl;
t--;
};
return 0;
}