fork download
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. double f(double x)
  9. {
  10. return(x*x/50);
  11. }
  12. double f2(double x)
  13. {
  14. return(1+x*x/100-x/200);
  15. }
  16.  
  17. int main()
  18. {
  19. const int N = 1000;
  20. double xp,xk,s,dx, s2;
  21. int i;
  22.  
  23. cout << setprecision(2)
  24. << fixed;
  25. xp=0;
  26. xk=10;
  27. int Ax, Ay, Bx, By, Cx, Cy, Dx, Dy;
  28. s = 0;
  29. s2 = 0;
  30. dx = (xk - xp) / N;
  31. for(i = 1; i <= N; i++) s += f(xp + i * dx);
  32. s *= dx;
  33. dx = (xk - xp) / N;
  34. for(i = 1; i <= N; i++) s2 += f2(xp + i * dx);
  35. s2 *= dx;
  36. cout<<"a) "<<s+s2<<endl;
  37. int j=0;
  38. while(f(j)+f2(j)<9999999999999)
  39. {
  40. j++;
  41. if(f(j)+f2(j)>=26)
  42. {
  43. j+=1;
  44. Ax=j;
  45. Dx=j;
  46. Bx=j+100;
  47. Cx=Bx;
  48. Ay=-f(j);
  49. By=Ay;
  50. Cy=f2(j);
  51. Dy=Cy;
  52. break;
  53. }
  54. }
  55. cout<<"b) "<<"Najmniejsza wartość C to "<<j+100<<endl<<"A = ("<<Ax<<", "<<Ay<<")"<<endl;
  56. cout<<"B = ("<<Bx<<", "<<By<<")"<<endl;
  57. cout<<"C = ("<<Cx<<", "<<Cy<<")"<<endl;
  58. cout<<"D = ("<<Dx<<", "<<Dy<<")"<<endl;
  59. return 0;
  60. }
Success #stdin #stdout 0.01s 5532KB
stdin
Standard input is empty
stdout
a) 19.76
b) Najmniejsza wartość C to 130
A = (30, -18)
B = (130, -18)
C = (130, 9)
D = (30, 9)