Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1567906
  • 博文数量: 354
  • 博客积分: 8137
  • 博客等级: 中将
  • 技术积分: 5137
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-26 15:40
文章分类

全部博文(354)

文章存档

2010年(300)

2009年(54)

分类: C/C++

2010-06-20 06:14:26

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
    double s, t, x;
    int n;
    printf("please input x:");
    scanf("%lf", &x);

    t = x;
    n = 1;
    s = x;

    do
    {
        n = n + 2;
        t = t * (-x*x)/((float)(n) - 1)/(float)(n);
        s = s + t;
    }
    while(fabs(t) >= 1e-8);
    printf("sin(%f) = %lf\n", x , s);

    system("pause");
    return 0;


}


阅读(832) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~