#include
#include
void main ( void )
{
int nNum;
float fResult = 0.0;
printf ( "input the n: " );
scanf( "%d", &nNum );
printf ( "Calculating...\n" );
while( nNum > 0 )
{
fResult = fResult + ( 1 / ( float( nNum ) * float( nNum + 1 ) ) );
nNum--;
}
printf( "Result is %.3f", fResult );
}
#include
void main()
{
int i;
int n = 10; //假设n = 10
double S = 0;
for(i = 1; i <= n; i++)
{
S += 1.0 / (i * (i+1));
}
printf("%f", S);
}
int i;
int n;
double sum;
cout<<"请输入一个N 的值:";
cin>>n;
for (i=1;i
s=s+1/i*(i+1);
}
cin>>s;