#include <stdio.h>
void main()
{
long p;
int n;
double q;
printf("------------------------------------------\n");
printf("2 to power n n 2 to power -n\n");
printf("------------------------------------------\n");
p = 1;
for(n = 0; n < 21; n++)/*loop begins*/
{
if(n==0)
p = 1;
else
p = p*2;
q = 1.0/(double)p;
printf("%10d %10d %20.10f\n",p,n,q);
}/*loop ends*/
printf("-------------------------------------------\n");
}
转载于:https://my.oschina.net/u/241930/blog/398294