谢谢了~~
这道题我都不知道怎么做~~
我们才学完循环~~
郁闷啊~~
谢谢大家了
麻烦了
#include "stdio.h"
#include "conio.h"
main()
{
int legs;
int heads;
int rabbits;
int cocks;
printf("input the legs\n" );
scanf("%d",&legs);
printf("\n" );
printf("input the heads\n" );
scanf("%d",&heads);
printf("\n" );
rabbits = legs / 2 - heads; /*好好理解一下这里的算法*/
cocks = heads - rabbits;
printf("the rabbits is %d\n", rabbits);
printf("the cocks is %d\n", cocks);
getch();
}
/*农场里有兔子和鸡,兔子的脚+鸡的脚等于M只,兔子的头+鸡的头等于N只,编程分别求出兔子和鸡的个数?*/
#include<stdio.h>
int main(void)
{
int r=0,c=0;
int m=0,n=0;
puts("Please input m,n:\n");
scanf("%d %d",&m,&n);
for(r=1;r<=(int)m/4&&r<n;r++)
for(c=1;c<=(int)m/2&&c<n;c++)
if(4*r+2*c==m&&r+c==n)
printf("the number of rabbit is: %d\nthe number of chick is: %d\n",r,c);
printf("The number you gived is wrong! Impossible!\n\n");
}