Quick actions

cmd+k|ctrl+k

Navigation

Languages

Lab7 (905)

Snippet info

Language

Cpp

Visibility

public

Author

buteskul5.6

Created

2018-11-28T17:38:11Z

Updated

2018-12-05T10:44:08Z

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	setlocale(LC_ALL, "ru");
	int n;
	cout << "Введите количество точек" << endl;
	cin >> n;
	int *x = new int[n];
	int *y = new int[n];

	double max = 0, a, c, s = 0;

	cout << "Введите точки" << endl;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i];
	}

	cout << "Вывод массивов на экран" << endl;
	cout << "X: ";
	for (int i = 0; i < n; i++)
	{
		cout << x[i] << " ";
	}
	cout << endl;
	cout << "Y: ";
	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;
	   	  
	delete[] x;
	delete[] y;
	return 0;
}

INFO