1.计算:S=1+1/2+1/3+1/4+......+1/100
1.计算:S=1+1/2+1/3+1/4+......+1/100
main( )
{float s; int i;
i=1;
s=0;
while(i<=100)
{ s+=1.0/i;
i++;
} printf("%f %d\n",s,i);
}
2. 计算 S=1+2+4+8+16+32
#include "math.h"
main( )
{ int i,s;
i=1;
s=0;
while(i<=6)
{ s+=pow(2,i-1);
i++;
}
printf("s=%d\n",s);
}
flydreams
2006-03-24 21:52:52
评论:1
阅读:1443
引用:0
评价
@2008-02-10 22:46:55 游客
要用计算机,还要你干身麽?你真是个大废物。
