貌似应改成这样:一元=1分×100/2分×50/5分×20或者把一元改成一角答案不变(没有运行不知道是否正确)
#include <iostream.h>
#define N 100
void main()
{
int one,two,three;
int num=0,q=0;
cout<<"一分\t"<<"二分\t"<<"三分\t"<<endl;
for(one=0;one<=100;one++)
for(two=0;two<=50;two++)
for(three=0;three<=20;three++)
{
num=one+two+three;
if(num==N)
{
q++;
cout<<one<<"\t"<<two<<"\t"<<three<<endl;
}
}
cout<<"共有"<<q<<"种分法"<<endl;}
[ 本帖最后由 lansir 于 2008-5-2 09:54 编辑 ]