Cod sursa(job #1918313)

Utilizator mworkgMaxim Stepanov mworkg Data 9 martie 2017 14:56:14
Problema Cele mai apropiate puncte din plan Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.76 kb
#include <fstream>
#include <math.h>

using namespace std;

ifstream cin("cmap.in");
ofstream cout("cmap.out");

float distanta(long n1, long m1, long n2, long m2) {
    return sqrt(pow((n1-n2),2)+pow((m1-m2),2));
}

int main() {
    long long int puncte;
    float punct[100000][2];
    float dis,totaldis;
    cin >> puncte;
    for (int i = 0; i < puncte; i++) {
        cin >> punct[i][0] >> punct[i][1];
    }
    for (int i = 0; i < puncte; i++) {
        for (int j = i; j < puncte; j++) {
            // Itteration
            if (i != j) {
            dis = distanta(punct[i][0], punct[i][1], punct[j][0], punct[j][1]);
            if ((dis < totaldis)) { totaldis = dis; }
            }
            // Itteration
        }
    }

    cout << totaldis;
    return 0;
}