哥们,你弄反了吧?
大循环在外面,跨切循环的次数越多,效率反而低了呀,小弟愚钝,望明示。谢谢
me too,还请明示
[此贴子已经被作者于2007-1-24 21:11:10编辑过]
#include "stdio.h"
main()
{
int a,b,c,d,e,f,s=0;
for(a=0;a<=2;a++)
for(b=0;b<=5;b++)
for(c=0;c<=10;c++)
for(d=0;d<=20;d++)
for(e=0;e<=50;e++)
{
if((f=100-(50*a+20*b+10*c+5*d+2*e))>=0&&f<=100)
{
s=s+1;
printf("the %d is:%d ge wu mao,%d ge liang mao,%d geyi mao,%d ge wu fen,%d ge liang fen,%d ge yi fen.\n",s,a,b,c,d,e,f);
}
}
}
#include "stdio.h"
main()
{
int a,b,c,d,e,f,s=0;
for(a=0;a<=2;a++)
for(b=0;b<=5;b++)
for(c=0;c<=10;c++)
for(d=0;d<=20;d++)
for(e=0;e<=50;e++)
{
if((f=100-(50*a+20*b+10*c+5*d+2*e))>=0&&f<=100)
{
s=s+1;
printf("the %d is:%d ge wu mao,%d ge liang mao,%d geyi mao,%d ge wu fen,%d ge liang fen,%d ge yi fen.\n",s,a,b,c,d,e,f);
}
}
}
这个好像更快!