小白求教,为啥我做的这个代码运行后是空的
#include<stdio.h>int main()
{
int a=1;
float sum=0,i,b;
i=1/a;
b=(i<0)?-i:i;
for(i=1/a;b>=1e-6;a=-(a+2))
{
sum=sum+i;
}
sum=sum+i;
printf("%f\n",sum);
return 0;
}
#include <stdio.h> int main( void ) { double sum = 0; for( unsigned i=0; ; ++i ) { sum += (1.0-i%2*2)/(2*i+1); if( 1.0/(2*i+1) < 1e-6 ) break; } printf( "%f\n", sum ); }