Pagini recente » Cod sursa (job #3285051) | Cod sursa (job #208765) | Cod sursa (job #3275770) | Cod sursa (job #153534) | Cod sursa (job #405560)
Cod sursa(job #405560)
#include <cmath>
#include <vector>
#include <fstream>
#include <iomanip>
#include <iterator>
#define aproximation 1e-10
/*
*
*/
using namespace std;
struct pr
{
double first, second;
pr( void ) { first=second=0.0; }
pr( const double& _f, const double& _s ) : first(_f), second(_s) { }
};
inline istream& operator>>( istream& in, pr& x )
{
in>>x.first>>x.second;
return in;
}
inline double dis( const pr& x, const pr& y )
{
return ( x.first-y.first )*( x.first-y.first )+( x.second-y.second )*( x.second-y.second );
}
vector< pr > v;
int main( void )
{
int N, i, j;
double d=1e+25, d2;
ifstream in( "cmap.in" );
in>>N;
copy( istream_iterator<pr>(in), istream_iterator<pr>(), back_inserter(v) );
for( i=0; i < N; ++i )
for( j=i+1; j < N; ++j )
{
d2=dis( v[i], v[j] );
if( d-d2 >= aproximation )
d=d2;
}
ofstream out( "cmap.out" );
out<<setprecision(20)<<sqrt(d);
return EXIT_SUCCESS;
}