| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 486 人关注过本帖
标题:高手来,求真相 (英文滴...)
只看楼主 加入收藏
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
快速回复:高手来,求真相 (英文滴...)
数据加载中...
 
   



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

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