百钱买百鸡:鸡翁一值钱五,鸡母一值钱三,鸡雏三值钱一。百钱买百鸡,问鸡翁、鸡母、鸡雏各几何?
#include<stdio.h>
int main()
{int i,j,k;for(i=1;i<=100;i++)for(j=1;j<=100;j++){k=100-i-j;if(k!=0)if(k%3==0)if(3*i+2*j+k/3==100)printf("母鸡=%d,公鸡=%d,小鸡=%d\n",i,j,k);}return 0;
}
#include<stdio.h>
int main()
{int i,j,k;i=1,j=1,k=1;for(i=1;i<=100;i++)for(j=1;j<=100;j++)for(k=1;k<=100;k++){if(3*i+2*j+k/3==100&&i+j+k==100&&k%3==0)printf("公鸡=%-2d,母鸡=%-2d,小鸡=%-2d\n",i,j,k);} return 0;
}