S=20+21+22+23+......+2n,直到S<=100.帮我看一下,我那里编错了,谢谢!#include <math.h>#include <stdio.h>int main(void){int x = 2, y = 0,s=0;return 0; while(s<=100) { s=s+pow(x,y); ++y;} printf("%d", s);}
[此贴子已经被作者于2007-9-14 12:26:16编辑过]
#include <stdio.h>#include <math.h>
int main(void){ int s=0,x=2,y=0; while (y<=100) { s=s+(int) pow(x,y); /*如果这里不转换的话。。会变成负数。。*/ y++; } printf ("%d",s); getch(); }