Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- ifstream in("in.txt");
- ofstream out("out.txt");
- struct point {
- int x, y, z;
- };
- double rass(point a, point b) {
- return sqrt(pow(b.x - a.x, 2) + pow(b.y - a.y, 2) + pow(b.z - a.z, 2));
- }
- int main() {
- setlocale(LC_ALL, "russian");
- point a[10];
- double sumras=0, minras=UINT_MAX;
- int nump;
- for (int i = 0; i < 10; i++) {
- in >> a[i].x >> a[i].y >> a[i].z;
- }
- for (int i = 0; i < 10; i++) {
- for (int j = 0; j < 10; j++) {
- sumras += rass(a[i],a[j]);
- }
- if (sumras < minras) {
- minras = sumras;
- nump = i;
- }
- out <<i <<'='<< sumras << endl;
- sumras = 0;
- }
- out <<"Точка "<<nump+1<<" имеет минимальную сумму расстояний ="<< minras;
- system("pause");
- return 0;
- in.close();
- out.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement