#include <stdio.h>
#define SQUARES 64
int main()
{
	int check ;									//定义“格子”的变量
	double grain, total;						//定义“谷物”的变量和“总计”的变量
	const double CROP = 2E16;					//只读变量“世界粮食产量”

	printf("Check\t\tGrain\t\tTotal\t\t     The ratio\n");
	printf(" Num\t\t NUM\t\t Num\t\tto world production\n");//打印表头

	check = 1;
	total = grain = 1.0;
	//printf("%3d\t%14.2E\t%14.2E\t%22.2E\n", check, grain, total, total / CROP);//第1个方格

	while (check <= SQUARES)
	{				
		printf("%3d\t%14.2E\t%14.2E\t%22.2E\n", check, grain, total, total / CROP);
		check = check + 1;
		grain = grain * 2;
		total = total + grain;
	}
	printf("That is all.\n");
	return 0;
}

程序运行结果图

2-1指数增长的程序方法_#include

2-1指数增长的程序方法_3d_02

2-1指数增长的程序方法_3d_03