Quick actions

cmd+k|ctrl+k

Navigation

Languages

lab6 5

Snippet info

Language

Cpp

Visibility

public

Author

enifmankalinan

Created

2018-12-10T20:40:09Z

Updated

2018-12-10T20:40:09Z

#include <iostream>
#include<cmath>

using namespace std;

int main()
{
	setlocale(LC_ALL, "ru");
	int x[30], y[30];
	double max = 0, a, c, s=0;
	int n;
	
	cout << "Введите количество пар точек" << endl;
	cin >> n;
	cout<<"Введите точки"<<endl;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i]	>> y[i];
	}

	for (int i = 0; i < n; i++)
	{
		cout << x[i] << " ";
	}
	cout << endl;
	for (int i = 0; i < n; i++)
	{
		cout << y[i] << " ";
	}
	
	for (int i = 0; i < n; i++)
	{
		for (int j = i; j < n; j++)
		{
			s += sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
			if (s > max) 
			{ 
				max = s; 
				a = i;
				c = j; 
			}
		}
	}
	cout << endl <<"Найбольшее расстояние между точками: "<< a <<" "<< c << endl;
	
	return 0;
}
INFO