| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 446 人关注过本帖
标题:这个 是怎么出来的
只看楼主 加入收藏
a132266
Rank: 2
等 级:论坛游民
帖 子:86
专家分:20
注 册:2015-3-26
结帖率:66.67%
收藏
已结贴  问题点数:20 回复次数:3 
这个 是怎么出来的
int main (void)
{
   
    int          t_ct;
    double       time, x;
    int          limit;
   
   
    printf("Enter the number of terms you want: ");
    scanf ("%d",&limit);
    for(time=0,x=1,t_ct=1;   t_ct<=limit;     t_ct++,x *=2.0 )    /*   t_ct = t_ct * 2.0  */
    {
        time += 1.0/x;                                            //   time = tinme + 1.0/x;
        printf("time = %f when terms = %d.\n",time,t_ct);
        
        
        
        
    }
}
   



    for(time=0,x=1,t_ct=1;   t_ct<=limit;     t_ct++,x *=2.0 )  求帮忙指点下这行 有点不太明白
搜索更多相关主题的帖子: double number terms Enter 
2015-04-05 20:13
a132266
Rank: 2
等 级:论坛游民
帖 子:86
专家分:20
注 册:2015-3-26
收藏
得分:0 
Enter the number of terms you want: 15
time = 1.000000 when terms = 1.
time = 1.500000 when terms = 2.
time = 1.750000 when terms = 3.
time = 1.875000 when terms = 4.
time = 1.937500 when terms = 5.
time = 1.968750 when terms = 6.
time = 1.984375 when terms = 7.
time = 1.992188 when terms = 8.
time = 1.996094 when terms = 9.
time = 1.998047 when terms = 10.
time = 1.999023 when terms = 11.
time = 1.999512 when terms = 12.
time = 1.999756 when terms = 13.
time = 1.999878 when terms = 14.
time = 1.999939 when terms = 15.

--------------------------------
Process exited with return value 0
Press any key to continue . . .                                   编译运行后
2015-04-05 20:16
longwu9t
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:6
帖 子:732
专家分:2468
注 册:2014-10-9
收藏
得分:0 
程序代码:
#include <stdio.h>

int main(void) {
    int i, terms;
    double time = 0, x = 1.0;

    printf("Enter the number of terms you want: ");
    scanf("%d", &terms);

    for(i = 1; i <= terms; i++) {
        time += 1 / x;
        x *= 2;
        printf("time = %f when terms = %d.\n", time, i);
    }
}


计算分散利率???

Only the Code Tells the Truth             K.I.S.S
2015-04-05 20:39
lzlz1111
Rank: 2
等 级:论坛游民
帖 子:19
专家分:54
注 册:2015-3-13
收藏
得分:20 
x=x+1/2^n;求极限
2015-04-05 21:40
快速回复:这个 是怎么出来的
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028375 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved