int mat[5] = {0,1,1,1,0};
for(int a = 0; a <= mat[0]; a++)
for(int b = 0; b <= mat[1]; b++)
for(int c = 0; c <= mat[2]; c++)
for(int d = 0; d <= mat[3]; d++)
for(int e = 0; e <= mat[4]; e++)
{
if(a && mat[a])
cout << 1;
else
cout << 0;
if(b && mat[b])
cout << 1;
else
cout << 0;
if(c && mat[c])
cout << 1;
else
cout << 0;
if(d && mat[d])
cout << 1;
else
cout << 0;
if(e && mat[e])
cout << 1;
else
cout << 0;
cout << endl;
};