|
楼主 |
发表于 2016-12-6 20:04:53
|
显示全部楼层
# include<stdio.h>
int main ()
{
int x[3],y[3],z[3];
for(x[0]=0;x[0]<=7;x[0]++)
for(x[1]=0;x[1]<=7-x[0];x[1]++)
for(x[2]=0;x[2]<=7-x[0]-x[1];x[2]++)
for(y[0]=0;y[0]<=7;y[0]++)
for(y[1]=0;y[1]<=7-x[0];y[1]++)
for(y[2]=0;y[2]<=7-x[0]-x[1];y[2]++)
for(z[0]=0;z[0]<=7;z[0]++)
for(z[1]=0;z[1]<=7-x[0];z[1]++)
for(z[2]=0;z[2]<=7-x[0]-x[1];z[2]++)
{if(x[0]+y[0]+z[0]==x[1]+y[1]+z[1]&&x[1]+y[1]+z[1]==x[2]+y[2]+z[2]&&x[1]+x[0]+x[2]==7&&y[1]+y[2]+y[0]==7&&z[0]+z[1]+z[2]==7)
if(x[0]*2+y[0]==x[1]*2+y[1]&&x[1]*2+y[1]==x[2]*2+y[2])
if(x[0]+y[0]+z[0]+x[1]+y[1]+z[1]+x[2]+y[2]+z[2]==21)
{
printf("%d满筐,%d半筐,%d空筐。\n",x[0],y[0],z[0]);
printf("%d满筐,%d半筐,%d空筐。\n",x[1],y[1],z[1]);
printf("%d满筐,%d半筐,%d空筐。\n\n",x[2],y[2],z[2]);
}
}
return 0;
}
|
|