1.Написать функцию Dist (x 1, y 1, x 2, y 2) вещественного типа, которая исчисляется расстояниям между двумя точками с заданными координатами (x 1, y 1) и (x 2, y 2) на плоскости по формуле: (x 2 - x 1) 2 + (y 2 - y 1) 2. С помощью эту подпрограмму найти расстояния между тремя парами точек, по данным их координатами. 2. Пользователь вводит целое число. Вывести все целые числа, на которое заданное число делиться без остатка.
2. #include <iostream> using namespace std; int main() { setlocale(LC_ALL, "Russian"); int a; cout << "Введите ваше число:" << endl; cin >> a; for (int i = 1; i <= a; i++) { if (a % i == 0) { cout << i << " "; } } return 0; } C #include <iostream> using namespace std; int main() { setlocale(LC_ALL, "Russian"); int a; cout << "Введите ваше число:" << endl; cin >> a; for (int i = 1; i <= a; i++) { if (a % i == 0) { cout << i << " "; } } return 0; }
1. #include <iostream> class Point { public: float x; float y; Point(float x,float y) { this->x = x; this->y = y; } }; float GetDist(Point point1, Point point2); int main() { Point point1(5,6); Point point2(1,12); std::cout << GetDist(point1, point2); system("pause"); return 0; } float GetDist(Point point1, Point point2) { return sqrt((point1.x - point2.x) * (point1.x - point2.x) + (point1.y - point2.y) * (point1.y - point2.y)); } C #include <iostream> class Point { public: float x; float y; Point(float x,float y) { this->x = x; this->y = y; } }; float GetDist(Point point1, Point point2); int main() { Point point1(5,6); Point point2(1,12); std::cout << GetDist(point1, point2); system("pause"); return 0; } float GetDist(Point point1, Point point2) { return sqrt((point1.x - point2.x) * (point1.x - point2.x) + (point1.y - point2.y) * (point1.y - point2.y)); }