已知 S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+N) ,当N的值为50时,求S的值。要求:按四舍五入的方式精确到小数点后第四位。
#include stdio.h
#includemath.h
main()
{float s=0.0;
int n,t=0;
for(n=1;n=50;n++)
{t=t+n;
s=s+1.0/t;
}
printf(%7.4f,s);
} 1.9608 把一张一元钞票,换成一分、二分和五分硬币,每种至少11枚,问有多少种方案?
#include stdio.h
void main()
{int x,y,z,count=0;
for(x=11;x=100; x++; )
{for(y=11;y=50; y++; )
{ for(z=11;z=20;z++)
{if(x+2*y+5*z==100)
printf(“x=%d,y=%d,z=%d”,x,y,z);
count++;
}
}
}
printf(“there are %d m
原创力文档

文档评论(0)