Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
WA啊!大牛们指点指点!#include<iostream> using namespace std; struct point { int x,y; }s[250]; int mycompare(const void *elem1,const void *elem2) { return *(double *)elem1-*(double *)elem2; } int main() { int n,i,j,accouts=0,t; bool flag=false; double k[41000],m=100000000.0; cin>>n; for(i=1;i<=n;i++) cin>>s[i].x>>s[i].y; t=0; for(i=1;i<=n;i++) { for(j=i+1;j<=n;j++) { if(s[i].x != s[j].x) { k[t]=(double)(s[j].y-s[i].y)/(double)(s[j].x-s[i].x); t++; } else if(s[i].x==s[j].x) { k[t]=m; t++; } } } qsort(k,t,sizeof(double),mycompare); cout<<endl; for(i=0;i<t;i++) { if(k[i]==k[i+1]) accouts++; } if(t==0) cout<<"0"<<endl; else cout<<t-accouts<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator