fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main(void) {
  5. double Tm,a,b, h, ci;
  6. int i, No, m;
  7.  
  8. printf("aの値を入力してください");
  9. scanf("%lf", &a);
  10.  
  11. printf("bの値を入力してください");
  12. scanf("%lf", &b);
  13.  
  14. for(No = 1; No < 500; No++) {
  15. Tm = 0;
  16. m = No;
  17. h = (b - a) / m;
  18. ci = a + h;
  19. Tm = (exp(-pow(a, 2)) + exp(-pow(b, 2))) / 2;
  20. for(i = 1; i < m; i++) {
  21. Tm += exp(-pow(ci, 2));
  22. ci += h;
  23. }
  24. Tm *= h;
  25. printf("%8d %.12lf\n", No, Tm);
  26. }
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.01s 5280KB
stdin
-1000,1000
stdout
aの値を入力してくださいbの値を入力してください       1 500.000000000000
       2 250.000000000000
       3 166.666666666667
       4 125.000000000000
       5 100.000000000000
       6 83.333333333333
       7 71.428571428571
       8 62.500000000000
       9 55.555555555556
      10 50.000000000000
      11 45.454545454545
      12 41.666666666667
      13 38.461538461538
      14 35.714285714286
      15 33.333333333333
      16 31.250000000000
      17 29.411764705882
      18 27.777777777778
      19 26.315789473684
      20 25.000000000000
      21 23.809523809524
      22 22.727272727273
      23 21.739130434783
      24 20.833333333333
      25 20.000000000000
      26 19.230769230769
      27 18.518518518519
      28 17.857142857143
      29 17.241379310345
      30 16.666666666667
      31 16.129032258065
      32 15.625000000000
      33 15.151515151515
      34 14.705882352941
      35 14.285714285714
      36 13.888888888889
      37 13.513513513514
      38 13.157894736842
      39 12.820512820513
      40 12.500000000000
      41 12.195121951220
      42 11.904761904762
      43 11.627906976744
      44 11.363636363636
      45 11.111111111111
      46 10.869565217391
      47 10.638297872340
      48 10.416666666667
      49 10.204081632653
      50 10.000000000000
      51 9.803921568627
      52 9.615384615385
      53 9.433962264151
      54 9.259259259259
      55 9.090909090909
      56 8.928571428571
      57 8.771929824561
      58 8.620689655172
      59 8.474576271186
      60 8.333333333333
      61 8.196721311475
      62 8.064516129032
      63 7.936507936508
      64 7.812500000000
      65 7.692307692308
      66 7.575757575758
      67 7.462686567164
      68 7.352941176471
      69 7.246376811594
      70 7.142857142857
      71 7.042253521127
      72 6.944444444444
      73 6.849315068493
      74 6.756756756757
      75 6.666666666667
      76 6.578947368421
      77 6.493506493506
      78 6.410256410256
      79 6.329113924051
      80 6.250000000000
      81 6.172839506173
      82 6.097560975610
      83 6.024096385542
      84 5.952380952381
      85 5.882352941176
      86 5.813953488372
      87 5.747126436782
      88 5.681818181818
      89 5.617977528090
      90 5.555555555556
      91 5.494505494505
      92 5.434782608696
      93 5.376344086022
      94 5.319148936170
      95 5.263157894737
      96 5.208333333333
      97 5.154639175258
      98 5.102040816327
      99 5.050505050505
     100 5.000000000000
     101 4.950495049505
     102 4.901960784314
     103 4.854368932039
     104 4.807692307692
     105 4.761904761905
     106 4.716981132075
     107 4.672897196262
     108 4.629629629630
     109 4.587155963303
     110 4.545454545455
     111 4.504504504505
     112 4.464285714286
     113 4.424778761062
     114 4.385964912281
     115 4.347826086957
     116 4.310344827586
     117 4.273504273504
     118 4.237288135593
     119 4.201680672269
     120 4.166666666667
     121 4.132231404959
     122 4.098360655738
     123 4.065040650407
     124 4.032258064516
     125 4.000000000000
     126 3.968253968254
     127 3.937007874016
     128 3.906250000000
     129 3.875968992248
     130 3.846153846154
     131 3.816793893130
     132 3.787878787879
     133 3.759398496241
     134 3.731343283582
     135 3.703703703704
     136 3.676470588235
     137 3.649635036496
     138 3.623188405797
     139 3.597122302158
     140 3.571428571429
     141 3.546099290780
     142 3.521126760563
     143 3.496503496503
     144 3.472222222222
     145 3.448275862069
     146 3.424657534247
     147 3.401360544218
     148 3.378378378378
     149 3.355704697987
     150 3.333333333333
     151 3.311258278146
     152 3.289473684211
     153 3.267973856209
     154 3.246753246753
     155 3.225806451613
     156 3.205128205128
     157 3.184713375796
     158 3.164556962025
     159 3.144654088050
     160 3.125000000000
     161 3.105590062112
     162 3.086419753086
     163 3.067484662577
     164 3.048780487805
     165 3.030303030303
     166 3.012048192771
     167 2.994011976048
     168 2.976190476190
     169 2.958579881657
     170 2.941176470588
     171 2.923976608187
     172 2.906976744186
     173 2.890173410405
     174 2.873563218391
     175 2.857142857143
     176 2.840909090909
     177 2.824858757062
     178 2.808988764045
     179 2.793296089386
     180 2.777777777778
     181 2.762430939227
     182 2.747252747253
     183 2.732240437159
     184 2.717391304349
     185 2.702702702704
     186 2.688172043012
     187 2.673796791446
     188 2.659574468088
     189 2.645502645506
     190 2.631578947373
     191 2.617801047127
     192 2.604166666675
     193 2.590673575141
     194 2.577319587644
     195 2.564102564122
     196 2.551020408189
     197 2.538071066023
     198 2.525252525295
     199 2.512562814125
     200 2.500000000069
     201 2.487562189143
     202 2.475247524865
     203 2.463054187335
     204 2.450980392337
     205 2.439024390470
     206 2.427184466303
     207 2.415458937552
     208 2.403846154286
     209 2.392344498154
     210 2.380952381628
     211 2.369668247279
     212 2.358490567063
     213 2.347417841632
     214 2.336448599667
     215 2.325581397221
     216 2.314814817090
     217 2.304147468196
     218 2.293577984987
     219 2.283105026853
     220 2.272727277564
     221 2.262443444716
     222 2.252252259196
     223 2.242152474656
     224 2.232142867013
     225 2.222222233949
     226 2.212389394430
     227 2.202643188243
     228 2.192982475535
     229 2.183406136371
     230 2.173913070304
     231 2.164502195950
     232 2.155172450583
     233 2.145922789731
     234 2.136752186794
     235 2.127659632657
     236 2.118644135327
     237 2.109704719572
     238 2.100840426569
     239 2.092050313567
     240 2.083333453547
     241 2.074688934906
     242 2.066115861137
     243 2.057613350518
     244 2.049180535818
     245 2.040816564000
     246 2.032520595937
     247 2.024291806132
     248 2.016129382452
     249 2.008032525856
     250 2.000000450141
     251 1.992032381691
     252 1.984127559232
     253 1.976285233588
     254 1.968504667454
     255 1.960785135164
     256 1.953125922470
     257 1.945526326326
     258 1.937985654676
     259 1.930503226248
     260 1.923078370355
     261 1.915710426695
     262 1.908398745160
     263 1.901142685653
     264 1.893941617903
     265 1.886794921286
     266 1.879701984655
     267 1.872662206166
     268 1.865674993117
     269 1.858739761784
     270 1.851855937265
     271 1.845022953323
     272 1.838240252243
     273 1.831507284678
     274 1.824823509509
     275 1.818188393706
     276 1.811601412191
     277 1.805062047704
     278 1.798569790676
     279 1.792124139096
     280 1.785724598394
     281 1.779370681315
     282 1.773061907801
     283 1.766797804878
     284 1.760577906540
     285 1.754401753639
     286 1.748268893779
     287 1.742178881206
     288 1.736131276711
     289 1.730125647523
     290 1.724161567212
     291 1.718238615595
     292 1.712356378636
     293 1.706514448359
     294 1.700712422754
     295 1.694949905688
     296 1.689226506821
     297 1.683541841516
     298 1.677895530760
     299 1.672287201079
     300 1.666716484462
     301 1.661183018276
     302 1.655686445193
     303 1.650226413117
     304 1.644802575101
     305 1.639414589283
     306 1.634062118809
     307 1.628744831765
     308 1.623462401106
     309 1.618214504591
     310 1.613000824712
     311 1.607821048632
     312 1.602674868118
     313 1.597561979479
     314 1.592482083501
     315 1.587434885389
     316 1.582420094703
     317 1.577437425297
     318 1.572486595265
     319 1.567567326877
     320 1.562679346527
     321 1.557822384672
     322 1.552996175778
     323 1.548200458263
     324 1.543434974446
     325 1.538699470489
     326 1.533993696347
     327 1.529317405714
     328 1.524670355970
     329 1.520052308132
     330 1.515463026798
     331 1.510902280105
     332 1.506369839672
     333 1.501865480551
     334 1.497388981184
     335 1.492940123348
     336 1.488518692111
     337 1.484124475781
     338 1.479757265865
     339 1.475416857015
     340 1.471103046987
     341 1.466815636593
     342 1.462554429656
     343 1.458319232965
     344 1.454109856231
     345 1.449926112041
     346 1.445767815815
     347 1.441634785763
     348 1.437526842841
     349 1.433443810707
     350 1.429385515683
     351 1.425351786704
     352 1.421342455288
     353 1.417357355482
     354 1.413396323830
     355 1.409459199329
     356 1.405545823387
     357 1.401656039783
     358 1.397789694629
     359 1.393946636330
     360 1.390126715543
     361 1.386329785139
     362 1.382555700164
     363 1.378804317802
     364 1.375075497333
     365 1.371369100100
     366 1.367684989471
     367 1.364023030798
     368 1.360383091383
     369 1.356765040443
     370 1.353168749071
     371 1.349594090200
     372 1.346040938572
     373 1.342509170697
     374 1.338998664821
     375 1.335509300895
     376 1.332040960532
     377 1.328593526984
     378 1.325166885098
     379 1.321760921292
     380 1.318375523516
     381 1.315010581223
     382 1.311665985335
     383 1.308341628213
     384 1.305037403624
     385 1.301753206712
     386 1.298488933964
     387 1.295244483184
     388 1.292019753460
     389 1.288814645137
     390 1.285629059783
     391 1.282462900167
     392 1.279316070226
     393 1.276188475038
     394 1.273080020793
     395 1.269990614771
     396 1.266920165308
     397 1.263868581772
     398 1.260835774541
     399 1.257821654972
     400 1.254826135375
     401 1.251849128995
     402 1.248890549981
     403 1.245950313360
     404 1.243028335023
     405 1.240124531689
     406 1.237238820893
     407 1.234371120955
     408 1.231521350964
     409 1.228689430750
     410 1.225875280868
     411 1.223078822572
     412 1.220299977800
     413 1.217538669147
     414 1.214794819850
     415 1.212068353764
     416 1.209359195351
     417 1.206667269647
     418 1.203992502258
     419 1.201334819335
     420 1.198694147554
     421 1.196070414102
     422 1.193463546662
     423 1.190873473392
     424 1.188300122909
     425 1.185743424276
     426 1.183203306985
     427 1.180679700941
     428 1.178172536446
     429 1.175681744190
     430 1.173207255230
     431 1.170749000977
     432 1.168306913190
     433 1.165880923954
     434 1.163470965671
     435 1.161076971045
     436 1.158698873077
     437 1.156336605042
     438 1.153990100486
     439 1.151659293216
     440 1.149344117280
     441 1.147044506964
     442 1.144760396778
     443 1.142491721449
     444 1.140238415912
     445 1.138000415294
     446 1.135777654912
     447 1.133570070265
     448 1.131377597014
     449 1.129200170987
     450 1.127037728168
     451 1.124890204686
     452 1.122757536805
     453 1.120639660925
     454 1.118536513569
     455 1.116448031382
     456 1.114374151118
     457 1.112314809635
     458 1.110269943894
     459 1.108239490953
     460 1.106223387952
     461 1.104221572121
     462 1.102233980769
     463 1.100260551274
     464 1.098301221087
     465 1.096355927727
     466 1.094424608774
     467 1.092507201861
     468 1.090603644680
     469 1.088713874969
     470 1.086837830523
     471 1.084975449169
     472 1.083126668783
     473 1.081291427282
     474 1.079469662609
     475 1.077661312754
     476 1.075866315732
     477 1.074084609587
     478 1.072316132394
     479 1.070560822252
     480 1.068818617292
     481 1.067089455656
     482 1.065373275520
     483 1.063670015081
     484 1.061979612545
     485 1.060302006151
     486 1.058637134151
     487 1.056984934817
     488 1.055345346436
     489 1.053718307322
     490 1.052103755795
     491 1.050501630203
     492 1.048911868908
     493 1.047334410287
     494 1.045769192742
     495 1.044216154689
     496 1.042675234568
     497 1.041146370833
     498 1.039629501965
     499 1.038124566464