码迷,mamicode.com
首页 > 其他好文 > 详细

近似计算

时间:2014-12-03 19:03:32      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:io   sp   for   bs   nbsp   br   return   print   include   

#include<stdio.h>                                                     
int main()                                                            
{                                                                     
 double s=0, si,i;                                                    
 int n;                                                               
    for(int i=0;;i++)                                                 
 {                                                                    
  double term=1.0/(i*2+1);if(i%2==0)                                  
   if(i%2==0)                                                         
    s+=term;                                                          
   else s-=term;                                                      
   if(term<1e-6)break;                                                
  }                                                                   
  printf("%.6lf\n",s);                                                
  return 0;                                                           
}                                                                     
                                                                      

近似计算

标签:io   sp   for   bs   nbsp   br   return   print   include   

原文地址:http://www.cnblogs.com/freemain/p/4140661.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!