请教一个小问题!
											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);
}
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-09-14 11:41
	    2007-09-14 11:41
  
 2007-09-14 11:48
	    2007-09-14 11:48
   2007-09-14 11:51
	    2007-09-14 11:51
  
 2007-09-14 11:55
	    2007-09-14 11:55
  
 2007-09-14 11:57
	    2007-09-14 11:57
  [此贴子已经被作者于2007-9-14 12:26:16编辑过]

 2007-09-14 12:10
	    2007-09-14 12:10
  #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();
          }
          

 2007-09-14 12:23
	    2007-09-14 12:23
   2007-09-14 13:15
	    2007-09-14 13:15
   2007-09-14 13:42
	    2007-09-14 13:42