2025-03-06 19:56:07 +08:00

20 lines
511 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
鸡兔同笼《孙子算经》中记载“今有雉兔同笼上有三十五头下有九十四足问雉兔各几何编程计算鸡和兔子各有多少只。使用for循环
结果:
鸡有23只,兔有12只
-------------------------------------------------------*/
#include <stdio.h>
main()
{
int j,t;
/**********Program**********/
for(j=1;j<35;j++){
for(t=1;t<35;t++){
if(j*2+t*4==94 && j+t == 35)
/********** End **********/
printf("鸡有%d只,兔有%d只\n",j,t);
}
}
}