CANDLE: Whats wrong in my code??

#include
using namespace std;

int main() {
    int t,min,min_pos;
    scanf("%d",&t);
    while(t--)
    {
        int a[10];
        for(int i=0;i<10;i++)
        {
            scanf("%d",&a[i]);
        }
        int k=1;
        while(1)
        {
        	min=a[k];
        	min_pos=k;
        	//cout<<"k="<<k<<endl;
        	
        	for(int i=k;i<10;i++)
        	{
        		if(min>a[i])
        		{
        			min=a[i];
        			//cout<<endl<<"112345min="<<min<<endl;
        			min_pos=i;
        		}
        	}
        	//cout<<endl<<"min="<<min<<endl;
        	//cout<<endl<<"min_pos="<<min_pos<<endl;
        	
        	if(a[0]==0 &&k!=1)
        	{
        		printf("0");
        	//	cout<<"\n";
        		break;
        	}
        	if(min==0 && min_pos>0)
        	{
        		printf("%d",min_pos);
        	//	cout<<"\n";
        		k=0;
        		break;
        	}
        	else if(min!=0)
        	{
        		a[min_pos]--;
        		printf("%d",min_pos);
        	//	cout<<"\n";
        		k=0;
        	}
        }
        printf("\n");
    }
    return 0;
}

Well i got my mistake. I didnt hv to check min again and again. jst show the digits of min. taking case of zero into consideration.
Successful answer: http://www.codechef.com/viewsolution/3307847

problem link? what compiler do you use? i suggest ideone, for now

http://ideone.com/aNiH0a