标题:高手来,求真相 (英文滴...)
只看楼主
ap1989
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-10-27
结帖率:0
已结贴  问题点数:20 回复次数:1 
高手来,求真相 (英文滴...)
Write a C program that prints out all different possibilities of obtaining £1(1 pound)
using coins of values 2 pence, 5 pence, and 10 pence. Indicate how many
possibilities have been found. The output of your program may look like:

£1 = 50 x 2p
£1 = 45 x 2p + 2 x 5p
£1 = 40 x 2p + 4 x 5p



In total, there are 66 possibilities to make £1.


Hint: You may use loops to generate the number of coins n2, n5, and n10 of value 2,
5, and 10 pence respectively and use the formula £1=100p=2*n2+5*n5+10*n10.
搜索更多相关主题的帖子: 英文 求真 
2009-10-27 18:54
wangnange
Rank: 2
等 级:论坛游民
帖 子:1
专家分:20
注 册:2009-10-27
得分:20 
#include "stdio.h"
void main()
{
    int x,y,z;
    for(x=0;x<100;x++)
      {
          for(y=0;y<100;y++)
            {
                for(z=0;z<100;z++)
                  {
                      if(x*2+y*5+z*10==100)
                      printf("$1=%d*2p+%d*5p+%d*10p\n",x,y,z);
                  }
            }
      }  
   
}
2009-10-27 19:14



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-290146-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.108487 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved