你已经给出了4种不同的编程。
// (1)double p,i,t
p=1, t=1
i=1 唤核袜 和激
while(i<64)
{ p=p*2
t=t+p
i++
}
// (2)
double p,i,t
i=1
for( i<64)
{ p=p*2
t=t+p
i++
}
// (3)
double p,i,t
for(i=1,t=1i<64i++)
{ p=p*2
t=t+p
}
// (4)
double i,t
while(i<64)
{ t=t+pow(2,i)
氏指 i++
}
// wheat.h#include "stdio.h"
void main(void)
{
int index,each_cell,sum
double volume_wheat
for(index=1index<=CELLSindex++)
{
each_cell=2^(index-1)//每个格子麦子的数量
sum+=each_cell//统计麦子旦拍总数
}
volume_wheat=sum/模衫羡(1.42*108)
printf("麦子总数量:%d\n",sum)
printf("塌绝麦子的立方数:%lf\n",volume_wheat)
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)