Advertisement
Guest User

1

a guest
Apr 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. Тимофей Кузнецов, сегодня в 11:16
  2. #include "stdafx.h"
  3. #include <iostream>
  4. using namespace std;
  5. #include "point.h"
  6.  
  7. class Curve{
  8. public:
  9. virtual Point f(int k) = 0;
  10. friend double length(const Point &t, const Point& t1);
  11. };
  12.  
  13. Тимофей Кузнецов, сегодня в 11:15
  14. #include "stdafx.h"
  15. #include <iostream>
  16. #include "point.h"
  17. #include "Curve.h"
  18. #include "Polynome.h"
  19. #include <time.h>
  20. #include <math.h>
  21.  
  22.  
  23. Polynome::Polynome(const Point &p0, const Point &p1, const Point &p2){
  24. t = p0;
  25. t2 = p1;
  26. t3 = p2;
  27. }
  28.  
  29. Point Polynome:: f(int k){
  30. Point c;
  31. c = t3*k*k + t2*k + t;
  32. return c;
  33. }
  34.  
  35. Тимофей Кузнецов, сегодня в 11:15
  36. #include "stdafx.h"
  37. #include <iostream>
  38. #include "point.h"
  39. #include "Curve.h"
  40. #include <time.h>
  41. #include <math.h>
  42.  
  43. class Polynome : public Curve{
  44. private: Point t;
  45. Point t2;
  46. Point t3;
  47. public:
  48. Polynome(const Point &p0, const Point &p1, const Point &p2);
  49. Point f(int k);
  50. };
  51.  
  52. Тимофей Кузнецов, сегодня в 11:15
  53. #include "stdafx.h"
  54. #include <iostream>
  55. using namespace std;
  56.  
  57. class Point
  58. {
  59. private:
  60. double x;
  61. double y;
  62. public:
  63. Point(double _x=0., double _y=0.);
  64. Point operator + (const Point &p) const;
  65. Point& operator += (const Point &p);
  66. Point operator * (const Point &p)const;
  67. Point& operator = (const Point&p);
  68. friend double distance(const Point &p1, const Point &p2);
  69. friend Point operator *(const double &l, const Point &p);
  70. virtual ~Point();
  71. };
  72.  
  73. Тимофей Кузнецов, сегодня в 11:15
  74. #include "stdafx.h"
  75. #include <iostream>
  76. #include "point.h"
  77. #include <time.h>
  78. #include <math.h>
  79.  
  80.  
  81. Point:: Point(double _x= 0., double _y=0.){
  82. x = _x;
  83. y = _y;
  84. }
  85.  
  86. Point Point:: operator +(const Point &p) const{
  87. Point P1;
  88. P1.x = x + p.x;
  89. P1.y = y + p.y;
  90. return P1;
  91. }
  92.  
  93. Point& Point:: operator = (const Point&p){
  94. x = p.x;
  95. y = p.y;
  96. }
  97.  
  98. Point Point:: operator *(const Point &p) const{
  99. Point P1;
  100. P1.x = x * p.x;
  101. P1.y = y * p.y;
  102. return P1;
  103. }
  104.  
  105. Point& Point :: operator += (const Point &p){
  106. x = x*p.x;
  107. y = y* p.y;
  108. return *this;
  109. }
  110.  
  111. double distance(const Point &p1, const Point &p2){
  112. double i = 0;
  113. i = p1.x - p2.x;
  114. double j = 0;
  115. j = p1.y - p2.y;
  116. double k = 0;
  117. k = sqrt(i*i + j*j);
  118. return k;
  119. }
  120.  
  121. Point operator *(const double &l, const Point &p){
  122. Point p1;
  123. p1.x = p.x * l;
  124. p1.y = p.y * l;
  125. return p1;
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement