2.9舍罕王的失算

#include<stdio.h>
#include<math.h>
int main()
{
double sum =0;
/*定义doub1e型变量sum存放累加和*/
int i;
/*使用循环求累加和*/for(i=1;i<-64;i++)
sum-sum+pow (2,i-1);
printf("国王总共需要赏赐给宰相的麦子数为:\n%fNn", sum);
/*打印结果*/
}

 

posted @ 2023-05-12 22:56  痛苦代码源  阅读(7)  评论(0编辑  收藏  举报