Dyskusja wikireportera:Wyksztalcioch/Brudnopis

Treść strony nie jest dostępna w innych językach.
Z Wikinews, wolnego źródła informacji.
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;

struct punkt{
 int x;
 int y;   
};

int odleglosc(int x1,int x2,int y1,int y2){
    int x=(x1-x2?(x1-x2):-(x1-x2));
    int y=(y1-y2?(y1-y2):-(y1-y2));
    return x*x+y*y;
};

int main(void)
{
    int n;
    int t;
    scanf("%d", &t);
    while(t--){
        scanf("%d", &n);
        punkt tab[n];
        int min=999999;
        for(int i=0;i<n;i++){scanf("%d %d", &tab[i].x, &tab[i].y);}
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i!=j){
                    int a=odleglosc(tab[i].x, tab[j].x, tab[i].y, tab[j].y);
                    if(a<min)min=a;
                }
            }  
        }
        if(min!=999999)printf("%.2f\n", sqrt(min));
        else printf("0\n");
    }
    system("pause");
    return 0;
}