fork download
  1. #include<iostream>
  2. #include<cmath>
  3. #include<math.h>
  4. #include<vector>
  5. #include<stdio.h>
  6. #include<iomanip> //setprecision//
  7. #include<sstream>
  8. #include<string>
  9. #define precisio 4
  10. #define K 100
  11. using namespace std;
  12. double valors(double a, double b);
  13. double g(double x);
  14. double x;
  15. double a = x;
  16. double y(x);
  17. int i;
  18. int main () {
  19. cout << setprecision(precisio);
  20. cout << "Escriu l'interval de la funciĆ³" << endl;
  21. double a, b;
  22. cout << "\n a ="; cin >> a;
  23. cout << "\n b ="; cin >> b;
  24. cout << "Escriu la funcio" << endl; string s;
  25. cin >> s; cout << s;
  26. double y = printf(s.c_str());
  27. valors(a,b);
  28. }
  29.  
  30. double valors(double a, double b){
  31. int punts = K*(b-a) + 1; double amplada = (b-a)/K;
  32. cout << "\n\tx\tf(x)" << endl;
  33.  
  34. for (int i = 0; i < punts; i++) {
  35. cout << "\t" << a << "\t" << g(a) << endl;
  36. a = a + amplada; }
  37. }
  38. double g(double x){
  39. return y;
  40. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
Escriu l'interval de la funció

 a =
 b =Escriu la funcio

	x	f(x)
	-1.975	0
	-1.956	0
	-1.936	0
	-1.916	0
	-1.896	0
	-1.877	0
	-1.857	0
	-1.837	0
	-1.817	0
	-1.798	0
	-1.778	0
	-1.758	0
	-1.738	0
	-1.718	0
	-1.699	0
	-1.679	0
	-1.659	0
	-1.639	0
	-1.62	0
	-1.6	0
	-1.58	0
	-1.56	0
	-1.541	0
	-1.521	0
	-1.501	0
	-1.481	0
	-1.462	0
	-1.442	0
	-1.422	0
	-1.402	0
	-1.383	0
	-1.363	0
	-1.343	0
	-1.323	0
	-1.304	0
	-1.284	0
	-1.264	0
	-1.244	0
	-1.225	0
	-1.205	0
	-1.185	0
	-1.165	0
	-1.146	0
	-1.126	0
	-1.106	0
	-1.086	0
	-1.067	0
	-1.047	0
	-1.027	0
	-1.007	0
	-0.9876	0
	-0.9679	0
	-0.9481	0
	-0.9284	0
	-0.9086	0
	-0.8889	0
	-0.8691	0
	-0.8494	0
	-0.8296	0
	-0.8099	0
	-0.7901	0
	-0.7704	0
	-0.7506	0
	-0.7309	0
	-0.7111	0
	-0.6913	0
	-0.6716	0
	-0.6518	0
	-0.6321	0
	-0.6123	0
	-0.5926	0
	-0.5728	0
	-0.5531	0
	-0.5333	0
	-0.5136	0
	-0.4938	0
	-0.4741	0
	-0.4543	0
	-0.4346	0
	-0.4148	0
	-0.3951	0
	-0.3753	0
	-0.3556	0
	-0.3358	0
	-0.316	0
	-0.2963	0
	-0.2765	0
	-0.2568	0
	-0.237	0
	-0.2173	0
	-0.1975	0
	-0.1778	0
	-0.158	0
	-0.1383	0
	-0.1185	0
	-0.09876	0
	-0.07901	0
	-0.05926	0
	-0.03951	0
	-0.01975	0
	3.983e-15	0
	0.01975	0
	0.03951	0
	0.05926	0
	0.07901	0
	0.09876	0
	0.1185	0
	0.1383	0
	0.158	0
	0.1778	0
	0.1975	0
	0.2173	0
	0.237	0
	0.2568	0
	0.2765	0
	0.2963	0
	0.316	0
	0.3358	0
	0.3556	0
	0.3753	0
	0.3951	0
	0.4148	0
	0.4346	0
	0.4543	0
	0.4741	0
	0.4938	0
	0.5136	0
	0.5333	0
	0.5531	0
	0.5728	0
	0.5926	0
	0.6123	0
	0.6321	0
	0.6518	0
	0.6716	0
	0.6913	0
	0.7111	0
	0.7309	0
	0.7506	0
	0.7704	0
	0.7901	0
	0.8099	0
	0.8296	0
	0.8494	0
	0.8691	0
	0.8889	0
	0.9086	0
	0.9284	0
	0.9481	0
	0.9679	0
	0.9876	0
	1.007	0
	1.027	0
	1.047	0
	1.067	0
	1.086	0
	1.106	0
	1.126	0
	1.146	0
	1.165	0
	1.185	0
	1.205	0
	1.225	0
	1.244	0
	1.264	0
	1.284	0
	1.304	0
	1.323	0
	1.343	0
	1.363	0
	1.383	0
	1.402	0
	1.422	0
	1.442	0
	1.462	0
	1.481	0
	1.501	0
	1.521	0
	1.541	0
	1.56	0
	1.58	0
	1.6	0
	1.62	0
	1.639	0
	1.659	0
	1.679	0
	1.699	0
	1.718	0
	1.738	0
	1.758	0
	1.778	0
	1.798	0
	1.817	0
	1.837	0
	1.857	0
	1.877	0
	1.896	0
	1.916	0