Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #define ABS(x) ((x) < 0 ? -(x) : (x))
- typedef std::pair<double, double> Point;
- double count(Point points[]) {
- double sum = 0;
- for (int i = 0; i < 3; i++) {
- Point oppositeCenter;
- oppositeCenter.first = (points[i].first + points[(i + 1) % 3].first) / 2;
- oppositeCenter.second = (points[i].second + points[(i + 1) % 3].second) / 2;
- Point currentPoint = points[(i + 2) % 3];
- sum += sqrt(pow(currentPoint.first - oppositeCenter.first, 2.) +
- pow(currentPoint.second - oppositeCenter.second, 2.));
- }
- }
- int main() {
- Point points[3];
- for (int i = 0; i < 3; i++) {
- std::cout << "Input X" << i << ", Y" << i << ":" << std::endl;
- std::cin >> points[i].first >> points[i].second;
- }
- std::cout << "Sum of medians: " << count(points) << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment