标签:scanf log struct names its blog turn pos scan
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=10005;
struct point
{
double x;
double y;
int ipos;
};//斜率最大的两个点,一定相邻
double iMatr=-100;
bool cmp(point a,point b)
{
return a.x<b.x;
}
double getMatr(point a,point b)
{
return 1.0*(b.y-a.y)/(b.x-a.x);
}
int main()
{
point p[maxn];
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%lf%lf",&p[i].x,&p[i].y);
p[i].ipos=i;
}
sort(p+1,p+1+n,cmp);//排序
point Ta,Tb;
for(int i=1;i<=n-1;i++)
{
if(getMatr(p[i],p[i+1])>iMatr)
{
iMatr=getMatr(p[i],p[i+1]);
Ta=p[i];
Tb=p[i+1];
}
}
printf("%d %d\n",Ta.ipos,Tb.ipos);
}
标签:scanf log struct names its blog turn pos scan
原文地址:http://www.cnblogs.com/masterchd/p/7357218.html