fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <math.h>
  4. #include <fstream>
  5. #include <stdio.h>
  6. using namespace std;
  7.  
  8.  
  9.  
  10. double f(double x)
  11. {
  12. return exp(-2.9*x);
  13. }
  14. const int n=40;
  15. int main()
  16. {
  17. int i=0;
  18. double x=0.0,y=0.20,h=1/(double)n;
  19. for(int i=0;i<=n;i++)
  20. {
  21. x=h*(double)i;
  22. y=f(x);
  23. cout << x << " " << y;
  24.  
  25. }
  26. }
Success #stdin #stdout 0s 4332KB
stdin
Standard input is empty
stdout
0  10.025  0.9300660.05  0.8650220.075  0.8045280.1  0.7482640.125  0.6959340.15  0.6472650.175  0.6019990.2  0.5598980.225  0.5207420.25  0.4843250.275  0.4504540.3  0.4189520.325  0.3896520.35  0.3624020.375  0.3370580.4  0.3134860.425  0.2915630.45  0.2711730.475  0.2522080.5  0.234570.525  0.2181660.55  0.2029090.575  0.1887180.6  0.175520.625  0.1632460.65  0.1518290.675  0.1412110.7  0.1313360.725  0.1221510.75  0.1136080.775  0.1056630.8  0.09827360.825  0.09140090.85  0.08500880.875  0.07906380.9  0.07353450.925  0.0683920.95  0.0636090.975  0.05916061  0.0550232