lab6 5

Run Settings
LanguageC++
Language Version
Run Command
#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; }
Editor Settings
Theme
Key bindings
Full width
Lines