/*按照题意,编了个小程序,经win-tc测试,完全通过,请各位指点一二。*/
#include<stdio.h>
int main()
{
int t,j,tu,ji;
char x;
do
{
printf("***************************************************\n");
printf("现在,做一个小游戏:有鸡兔同笼,您输入总的头数和\n"
"总的脚数,然后系统会给出您鸡有几只,兔有几只。\n");
printf("***************************************************\n");
printf("请输入头的数量:");
scanf("
%d",&t);
puts(" ");
do
{
printf("请输入脚的数量:");
scanf("
%d",&j);
puts(" ");
if(j%2!=0)
printf("您的数据错误,不能有奇数的脚 ,请重新输入。\n");
}
while(j%2!=0);
for(tu=1;tu<t;tu++)
{
ji=t-tu;
if(2*ji+4*tu==j)
printf("鸡为%d只\n 兔为%d只\n",ji,tu);
}
printf("请问,您还要重玩吗?按N退出,其它键重来:\n");
scanf("
%c",&x);
}
while(x!='n'&&x!='N');
printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf("谢谢您的参与,再见!\n" );
getch();
}