| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1442 人关注过本帖
标题:C语言for训话初始值为负数-0.8,为什么运行结果第一项为0.02?
只看楼主 加入收藏
WANG_GE
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-3-1
结帖率:0
收藏
已结贴  问题点数:20 回复次数:6 
C语言for训话初始值为负数-0.8,为什么运行结果第一项为0.02?
int main(){
图片附件: 游客没有浏览图片的权限,请 登录注册

    double x=-0.80,Y,Y1,Y2,Yr;
    Y=log(x+1);//求ln(x+1)
    Y1=1/(x+1);
    Y2=-1/pow(x+1,2);//pow(x)平方函数
//    Yr=sqrt(pow((1+pow(1/(x+1),2)),3));
    for(x=-0.80;x<3.00;x=x+0.01){
        Y1=1/(x+1);
            printf("when x=%.6f,Y1=%.6f\n",x,Y1);
    }
求助!谢谢!
搜索更多相关主题的帖子: double C语言 
2017-03-01 14:08
WANG_GE
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-3-1
收藏
得分:0 
求帮助,初学渣!!!
2017-03-01 14:16
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9031
专家分:54061
注 册:2011-1-18
收藏
得分:4 
估计输出太多了,最开始的输出被覆盖了
2017-03-01 14:30
grmmylbs
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:54
帖 子:1409
专家分:5845
注 册:2016-2-14
收藏
得分:4 
你贴的代码和打印的内容对应不上。似乎不是一套代码
2017-03-01 14:35
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:4 
3楼说的对
这里是你的代码的全部输出

when x=-0.800000,Y1=5.000000
when x=-0.790000,Y1=4.761905
when x=-0.780000,Y1=4.545455
when x=-0.770000,Y1=4.347826
when x=-0.760000,Y1=4.166667
when x=-0.750000,Y1=4.000000
when x=-0.740000,Y1=3.846154
when x=-0.730000,Y1=3.703704
when x=-0.720000,Y1=3.571429
when x=-0.710000,Y1=3.448276
when x=-0.700000,Y1=3.333333
when x=-0.690000,Y1=3.225806
when x=-0.680000,Y1=3.125000
when x=-0.670000,Y1=3.030303
when x=-0.660000,Y1=2.941176
when x=-0.650000,Y1=2.857143
when x=-0.640000,Y1=2.777778
when x=-0.630000,Y1=2.702703
when x=-0.620000,Y1=2.631579
when x=-0.610000,Y1=2.564103
when x=-0.600000,Y1=2.500000
when x=-0.590000,Y1=2.439024
when x=-0.580000,Y1=2.380952
when x=-0.570000,Y1=2.325581
when x=-0.560000,Y1=2.272727
when x=-0.550000,Y1=2.222222
when x=-0.540000,Y1=2.173913
when x=-0.530000,Y1=2.127660
when x=-0.520000,Y1=2.083333
when x=-0.510000,Y1=2.040816
when x=-0.500000,Y1=2.000000
when x=-0.490000,Y1=1.960784
when x=-0.480000,Y1=1.923077
when x=-0.470000,Y1=1.886792
when x=-0.460000,Y1=1.851852
when x=-0.450000,Y1=1.818182
when x=-0.440000,Y1=1.785714
when x=-0.430000,Y1=1.754386
when x=-0.420000,Y1=1.724138
when x=-0.410000,Y1=1.694915
when x=-0.400000,Y1=1.666667
when x=-0.390000,Y1=1.639344
when x=-0.380000,Y1=1.612903
when x=-0.370000,Y1=1.587302
when x=-0.360000,Y1=1.562500
when x=-0.350000,Y1=1.538462
when x=-0.340000,Y1=1.515152
when x=-0.330000,Y1=1.492537
when x=-0.320000,Y1=1.470588
when x=-0.310000,Y1=1.449275
when x=-0.300000,Y1=1.428571
when x=-0.290000,Y1=1.408451
when x=-0.280000,Y1=1.388889
when x=-0.270000,Y1=1.369863
when x=-0.260000,Y1=1.351351
when x=-0.250000,Y1=1.333333
when x=-0.240000,Y1=1.315789
when x=-0.230000,Y1=1.298701
when x=-0.220000,Y1=1.282051
when x=-0.210000,Y1=1.265823
when x=-0.200000,Y1=1.250000
when x=-0.190000,Y1=1.234568
when x=-0.180000,Y1=1.219512
when x=-0.170000,Y1=1.204819
when x=-0.160000,Y1=1.190476
when x=-0.150000,Y1=1.176471
when x=-0.140000,Y1=1.162791
when x=-0.130000,Y1=1.149425
when x=-0.120000,Y1=1.136364
when x=-0.110000,Y1=1.123596
when x=-0.100000,Y1=1.111111
when x=-0.090000,Y1=1.098901
when x=-0.080000,Y1=1.086957
when x=-0.070000,Y1=1.075269
when x=-0.060000,Y1=1.063830
when x=-0.050000,Y1=1.052632
when x=-0.040000,Y1=1.041667
when x=-0.030000,Y1=1.030928
when x=-0.020000,Y1=1.020408
when x=-0.010000,Y1=1.010101
when x=0.000000,Y1=1.000000
when x=0.010000,Y1=0.990099
when x=0.020000,Y1=0.980392
when x=0.030000,Y1=0.970874
when x=0.040000,Y1=0.961538
when x=0.050000,Y1=0.952381
when x=0.060000,Y1=0.943396
when x=0.070000,Y1=0.934579
when x=0.080000,Y1=0.925926
when x=0.090000,Y1=0.917431
when x=0.100000,Y1=0.909091
when x=0.110000,Y1=0.900901
when x=0.120000,Y1=0.892857
when x=0.130000,Y1=0.884956
when x=0.140000,Y1=0.877193
when x=0.150000,Y1=0.869565
when x=0.160000,Y1=0.862069
when x=0.170000,Y1=0.854701
when x=0.180000,Y1=0.847458
when x=0.190000,Y1=0.840336
when x=0.200000,Y1=0.833333
when x=0.210000,Y1=0.826446
when x=0.220000,Y1=0.819672
when x=0.230000,Y1=0.813008
when x=0.240000,Y1=0.806452
when x=0.250000,Y1=0.800000
when x=0.260000,Y1=0.793651
when x=0.270000,Y1=0.787402
when x=0.280000,Y1=0.781250
when x=0.290000,Y1=0.775194
when x=0.300000,Y1=0.769231
when x=0.310000,Y1=0.763359
when x=0.320000,Y1=0.757576
when x=0.330000,Y1=0.751880
when x=0.340000,Y1=0.746269
when x=0.350000,Y1=0.740741
when x=0.360000,Y1=0.735294
when x=0.370000,Y1=0.729927
when x=0.380000,Y1=0.724638
when x=0.390000,Y1=0.719424
when x=0.400000,Y1=0.714286
when x=0.410000,Y1=0.709220
when x=0.420000,Y1=0.704225
when x=0.430000,Y1=0.699301
when x=0.440000,Y1=0.694444
when x=0.450000,Y1=0.689655
when x=0.460000,Y1=0.684932
when x=0.470000,Y1=0.680272
when x=0.480000,Y1=0.675676
when x=0.490000,Y1=0.671141
when x=0.500000,Y1=0.666667
when x=0.510000,Y1=0.662252
when x=0.520000,Y1=0.657895
when x=0.530000,Y1=0.653595
when x=0.540000,Y1=0.649351
when x=0.550000,Y1=0.645161
when x=0.560000,Y1=0.641026
when x=0.570000,Y1=0.636943
when x=0.580000,Y1=0.632911
when x=0.590000,Y1=0.628931
when x=0.600000,Y1=0.625000
when x=0.610000,Y1=0.621118
when x=0.620000,Y1=0.617284
when x=0.630000,Y1=0.613497
when x=0.640000,Y1=0.609756
when x=0.650000,Y1=0.606061
when x=0.660000,Y1=0.602410
when x=0.670000,Y1=0.598802
when x=0.680000,Y1=0.595238
when x=0.690000,Y1=0.591716
when x=0.700000,Y1=0.588235
when x=0.710000,Y1=0.584795
when x=0.720000,Y1=0.581395
when x=0.730000,Y1=0.578035
when x=0.740000,Y1=0.574713
when x=0.750000,Y1=0.571429
when x=0.760000,Y1=0.568182
when x=0.770000,Y1=0.564972
when x=0.780000,Y1=0.561798
when x=0.790000,Y1=0.558659
when x=0.800000,Y1=0.555556
when x=0.810000,Y1=0.552486
when x=0.820000,Y1=0.549451
when x=0.830000,Y1=0.546448
when x=0.840000,Y1=0.543478
when x=0.850000,Y1=0.540541
when x=0.860000,Y1=0.537634
when x=0.870000,Y1=0.534759
when x=0.880000,Y1=0.531915
when x=0.890000,Y1=0.529101
when x=0.900000,Y1=0.526316
when x=0.910000,Y1=0.523560
when x=0.920000,Y1=0.520833
when x=0.930000,Y1=0.518135
when x=0.940000,Y1=0.515464
when x=0.950000,Y1=0.512821
when x=0.960000,Y1=0.510204
when x=0.970000,Y1=0.507614
when x=0.980000,Y1=0.505051
when x=0.990000,Y1=0.502513
when x=1.000000,Y1=0.500000
when x=1.010000,Y1=0.497512
when x=1.020000,Y1=0.495050
when x=1.030000,Y1=0.492611
when x=1.040000,Y1=0.490196
when x=1.050000,Y1=0.487805
when x=1.060000,Y1=0.485437
when x=1.070000,Y1=0.483092
when x=1.080000,Y1=0.480769
when x=1.090000,Y1=0.478469
when x=1.100000,Y1=0.476190
when x=1.110000,Y1=0.473934
when x=1.120000,Y1=0.471698
when x=1.130000,Y1=0.469484
when x=1.140000,Y1=0.467290
when x=1.150000,Y1=0.465116
when x=1.160000,Y1=0.462963
when x=1.170000,Y1=0.460829
when x=1.180000,Y1=0.458716
when x=1.190000,Y1=0.456621
when x=1.200000,Y1=0.454545
when x=1.210000,Y1=0.452489
when x=1.220000,Y1=0.450450
when x=1.230000,Y1=0.448430
when x=1.240000,Y1=0.446429
when x=1.250000,Y1=0.444444
when x=1.260000,Y1=0.442478
when x=1.270000,Y1=0.440529
when x=1.280000,Y1=0.438596
when x=1.290000,Y1=0.436681
when x=1.300000,Y1=0.434783
when x=1.310000,Y1=0.432900
when x=1.320000,Y1=0.431034
when x=1.330000,Y1=0.429185
when x=1.340000,Y1=0.427350
when x=1.350000,Y1=0.425532
when x=1.360000,Y1=0.423729
when x=1.370000,Y1=0.421941
when x=1.380000,Y1=0.420168
when x=1.390000,Y1=0.418410
when x=1.400000,Y1=0.416667
when x=1.410000,Y1=0.414938
when x=1.420000,Y1=0.413223
when x=1.430000,Y1=0.411523
when x=1.440000,Y1=0.409836
when x=1.450000,Y1=0.408163
when x=1.460000,Y1=0.406504
when x=1.470000,Y1=0.404858
when x=1.480000,Y1=0.403226
when x=1.490000,Y1=0.401606
when x=1.500000,Y1=0.400000
when x=1.510000,Y1=0.398406
when x=1.520000,Y1=0.396825
when x=1.530000,Y1=0.395257
when x=1.540000,Y1=0.393701
when x=1.550000,Y1=0.392157
when x=1.560000,Y1=0.390625
when x=1.570000,Y1=0.389105
when x=1.580000,Y1=0.387597
when x=1.590000,Y1=0.386100
when x=1.600000,Y1=0.384615
when x=1.610000,Y1=0.383142
when x=1.620000,Y1=0.381679
when x=1.630000,Y1=0.380228
when x=1.640000,Y1=0.378788
when x=1.650000,Y1=0.377358
when x=1.660000,Y1=0.375940
when x=1.670000,Y1=0.374532
when x=1.680000,Y1=0.373134
when x=1.690000,Y1=0.371747
when x=1.700000,Y1=0.370370
when x=1.710000,Y1=0.369004
when x=1.720000,Y1=0.367647
when x=1.730000,Y1=0.366300
when x=1.740000,Y1=0.364964
when x=1.750000,Y1=0.363636
when x=1.760000,Y1=0.362319
when x=1.770000,Y1=0.361011
when x=1.780000,Y1=0.359712
when x=1.790000,Y1=0.358423
when x=1.800000,Y1=0.357143
when x=1.810000,Y1=0.355872
when x=1.820000,Y1=0.354610
when x=1.830000,Y1=0.353357
when x=1.840000,Y1=0.352113
when x=1.850000,Y1=0.350877
when x=1.860000,Y1=0.349650
when x=1.870000,Y1=0.348432
when x=1.880000,Y1=0.347222
when x=1.890000,Y1=0.346021
when x=1.900000,Y1=0.344828
when x=1.910000,Y1=0.343643
when x=1.920000,Y1=0.342466
when x=1.930000,Y1=0.341297
when x=1.940000,Y1=0.340136
when x=1.950000,Y1=0.338983
when x=1.960000,Y1=0.337838
when x=1.970000,Y1=0.336700
when x=1.980000,Y1=0.335570
when x=1.990000,Y1=0.334448
when x=2.000000,Y1=0.333333
when x=2.010000,Y1=0.332226
when x=2.020000,Y1=0.331126
when x=2.030000,Y1=0.330033
when x=2.040000,Y1=0.328947
when x=2.050000,Y1=0.327869
when x=2.060000,Y1=0.326797
when x=2.070000,Y1=0.325733
when x=2.080000,Y1=0.324675
when x=2.090000,Y1=0.323625
when x=2.100000,Y1=0.322581
when x=2.110000,Y1=0.321543
when x=2.120000,Y1=0.320513
when x=2.130000,Y1=0.319489
when x=2.140000,Y1=0.318471
when x=2.150000,Y1=0.317460
when x=2.160000,Y1=0.316456
when x=2.170000,Y1=0.315457
when x=2.180000,Y1=0.314465
when x=2.190000,Y1=0.313480
when x=2.200000,Y1=0.312500
when x=2.210000,Y1=0.311526
when x=2.220000,Y1=0.310559
when x=2.230000,Y1=0.309598
when x=2.240000,Y1=0.308642
when x=2.250000,Y1=0.307692
when x=2.260000,Y1=0.306748
when x=2.270000,Y1=0.305810
when x=2.280000,Y1=0.304878
when x=2.290000,Y1=0.303951
when x=2.300000,Y1=0.303030
when x=2.310000,Y1=0.302115
when x=2.320000,Y1=0.301205
when x=2.330000,Y1=0.300300
when x=2.340000,Y1=0.299401
when x=2.350000,Y1=0.298507
when x=2.360000,Y1=0.297619
when x=2.370000,Y1=0.296736
when x=2.380000,Y1=0.295858
when x=2.390000,Y1=0.294985
when x=2.400000,Y1=0.294118
when x=2.410000,Y1=0.293255
when x=2.420000,Y1=0.292398
when x=2.430000,Y1=0.291545
when x=2.440000,Y1=0.290698
when x=2.450000,Y1=0.289855
when x=2.460000,Y1=0.289017
when x=2.470000,Y1=0.288184
when x=2.480000,Y1=0.287356
when x=2.490000,Y1=0.286533
when x=2.500000,Y1=0.285714
when x=2.510000,Y1=0.284900
when x=2.520000,Y1=0.284091
when x=2.530000,Y1=0.283286
when x=2.540000,Y1=0.282486
when x=2.550000,Y1=0.281690
when x=2.560000,Y1=0.280899
when x=2.570000,Y1=0.280112
when x=2.580000,Y1=0.279330
when x=2.590000,Y1=0.278552
when x=2.600000,Y1=0.277778
when x=2.610000,Y1=0.277008
when x=2.620000,Y1=0.276243
when x=2.630000,Y1=0.275482
when x=2.640000,Y1=0.274725
when x=2.650000,Y1=0.273973
when x=2.660000,Y1=0.273224
when x=2.670000,Y1=0.272480
when x=2.680000,Y1=0.271739
when x=2.690000,Y1=0.271003
when x=2.700000,Y1=0.270270
when x=2.710000,Y1=0.269542
when x=2.720000,Y1=0.268817
when x=2.730000,Y1=0.268097
when x=2.740000,Y1=0.267380
when x=2.750000,Y1=0.266667
when x=2.760000,Y1=0.265957
when x=2.770000,Y1=0.265252
when x=2.780000,Y1=0.264550
when x=2.790000,Y1=0.263852
when x=2.800000,Y1=0.263158
when x=2.810000,Y1=0.262467
when x=2.820000,Y1=0.261780
when x=2.830000,Y1=0.261097
when x=2.840000,Y1=0.260417
when x=2.850000,Y1=0.259740
when x=2.860000,Y1=0.259067
when x=2.870000,Y1=0.258398
when x=2.880000,Y1=0.257732
when x=2.890000,Y1=0.257069
when x=2.900000,Y1=0.256410
when x=2.910000,Y1=0.255754
when x=2.920000,Y1=0.255102
when x=2.930000,Y1=0.254453
when x=2.940000,Y1=0.253807
when x=2.950000,Y1=0.253165
when x=2.960000,Y1=0.252525
when x=2.970000,Y1=0.251889
when x=2.980000,Y1=0.251256
when x=2.990000,Y1=0.250627
when x=3.000000,Y1=0.250000

DO IT YOURSELF !
2017-03-01 14:44
xzlxzlxzl
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖北
等 级:贵宾
威 望:125
帖 子:1091
专家分:5825
注 册:2014-5-3
收藏
得分:4 
for(x=-0.80;x<3.00;x=x+0.01){
改成:
for(x=-0.80;x<2.00;x=x+0.01){

只能连续显示300行数据
2017-03-01 14:49
mnmn4429
Rank: 4
等 级:业余侠客
帖 子:64
专家分:245
注 册:2017-2-21
收藏
得分:4 
同上,我刚实验了一下,发现没有错误,只是输出太多被覆盖了,你可以照楼上的说法试试,改成2.00就会从-0.8开始
2017-03-01 14:54
快速回复:C语言for训话初始值为负数-0.8,为什么运行结果第一项为0.02?
数据加载中...
 
   



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

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