打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
085.百钱百鸡问题
#include<stdio.h>
void main()
{
    int x,y,z,j=0;
    clrscr();
    puts("************************************************");
    puts("*      This program is to solve Problem of     *");
    puts("*           Hundred Yuan Hundred Fowls.        *");
    puts("*  Which is presented by Zhang Qiujiang,       *");
    puts("* a Chinese ancient mathematician, in his work *");
    puts("* Bible of Calculation: 5 Yuan can buy 1 cock, *");
    puts("* 3 Yuan can buy 1 hen, 1 Yuan buy 3 chickens, *");
    puts("* now one has 100 Yuan to buy 100 fowls, the   *");
    puts("* question is how many cocks, hens, chickens   *");
    puts("* to buy?                                      *");
    puts("************************************************");
    printf("\n The possible plans to buy 100 fowls with 100 Yuan are:\n\n");
    for(x=0;x<=20;x++)               /*外层循环控制鸡翁数*/
        for(y=0;y<=33;y++)           /*内层循环控制鸡母数y在0~33变化*/
        {
            z=100-x-y;             /*内外层循环控制下,鸡雏数z的值受x,y的值的制约*/
            if(z%3==0&&5*x+3*y+z/3==100)
                                   /*验证取z值的合理性及得到一组解的合理性*/
                printf("%2d: cock=%2d hen=%2d chicken=%2d\n",++j,x,y,z);
	}
    puts("\n Press any key to quit...");
    getch();
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Chicken feed不是喂鸡!我属鸡用英语怎么说?
《百钱买百鸡》的算法
鸡年到底是哪种鸡?Chicken、Rooster还是Cock
百钱买百鸡
“鸡年”到底怎么说?Chicken?Rooster?
Chicken or Rooster?鸡年英语怎么说?文末领新年福利
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服