fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. // Definicja funkcji
  7. double f(double x)
  8. {
  9. return 0.25 * x * x - 2;
  10. }
  11.  
  12. int main()
  13. {
  14. double x_start = 1.0;
  15. double x_end = 5.0;
  16. double step = 0.1;
  17.  
  18. cout << "x\tf(x)" << endl;
  19.  
  20. for (double x = x_start; x <= x_end; x += step)
  21. {
  22. cout << x << "\t" << f(x) << endl;
  23. }
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
x	f(x)
1	-1.75
1.1	-1.6975
1.2	-1.64
1.3	-1.5775
1.4	-1.51
1.5	-1.4375
1.6	-1.36
1.7	-1.2775
1.8	-1.19
1.9	-1.0975
2	-1
2.1	-0.8975
2.2	-0.79
2.3	-0.6775
2.4	-0.56
2.5	-0.4375
2.6	-0.31
2.7	-0.1775
2.8	-0.04
2.9	0.1025
3	0.25
3.1	0.4025
3.2	0.56
3.3	0.7225
3.4	0.89
3.5	1.0625
3.6	1.24
3.7	1.4225
3.8	1.61
3.9	1.8025
4	2
4.1	2.2025
4.2	2.41
4.3	2.6225
4.4	2.84
4.5	3.0625
4.6	3.29
4.7	3.5225
4.8	3.76
4.9	4.0025
5	4.25