</pre><pre class="cpp" name="code">
/*
*copyright (c)2014,烟台大学计算机学院
*All rights reserved
*文件名称:qwe.cpp
*作者:孙春红
*完成日期:2014年10月27日
*版本号:v1.0
*
*问题描述:用一元人民币兑换成一分,2分和5分的硬币,有多少种兑换的办法?
*程序输出:输出所有可能的方法
*
*/
#include <iostream>
using namespace std;
int main()
{
int n,a,x,count=0;
for (n=0; n<=100; n++)
for (a=0; a<=50; a++)
for (x=0; x<=20; x++)
if (n+a*2+x*5==100 )
{
++count;
cout<<count<<":" <<n<<" "<<a<<" "<<x<< endl;
}
cout <<endl;
return 0;
}
运行结果:
知识点总结:
学会使用穷举法解决组合问题
学习心得:
注意在写代码时符号的使用