想請問看看,為何這樣會逾時?(c)
#include"stdio.h"
#include"math.h"
double p,q;
double mymin(double p, double q)
{
if(p>q){return q;}
else {return p;}
}
int main()
{
int n,m,i,j,k;
while(scanf("%d%d",&n,&m)!=EOF)
{
int x[20],y[20];
for(i=1;i<=m;i++)
{
scanf("%d%d",&x[i],&y[i]);
}
double d,b,ans=10000;
for(i=1;i<=m-1;i++)
{
for(j=i+1;j<=m;j++)
{
d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
ans=mymin(ans,d);
}
}
printf("%0.4lf\n",ans);
}
return 0;
}
感恩!