/*describes the total number of chickens and rabbits known to be n and the total number of legs m. Enter n and m, output the number of chickens and rabbits in turn, and if no solution, output "no answer" (no quotation marks). Enter the first line to enter a data a, representing the next few sets of data, in the next (a<10) a row, each row has a N and M. (0<m,n<100) output number of chickens or rabbits, or no answer sample input 214 3210 16 Sample output 2No answer*//*2 2 No answer*/#include<stdio.h>intMainintargcConst Char*argv[]) { //Insert code here ... intn,m,flag=0, num; scanf ("%d",&num); while(num--) {scanf ("%d%d",&n,&m); for(intx=0;x< -; x + +) { for(inty=0;y< -; y++) { if((x+y) ==n&& (2*x+4*y) = =m) {flag=1; printf ("%d%d\n", x, y); } } } if(flag==0) {printf ("No answer\n"); } Flag=0; } return 0;}
Chicken and rabbit cage