#include<iostream> using namespace std; struct point { int x; int y; }; int cmp(const void *a,const void *b) //排序调用的函数,用那个凸包原理 { struct point *p,*q; int i; p = ( struct point * )a; q = ( struct point * )b; i = p->x*q->y - p->y*q->x; if(i>0) return -1; return 1; } int main() { point a[102]; int i=1,j; cin>>a[0].x>>a[0].y; while(cin>>a[i].x>>a[i].y)//不知道什么时候退出,自己测试时写成了while(cin>>a[i].x>>a[i].y&&a[i].x) i++; qsort(a+1,i-1,sizeof(a[0]),cmp); cout<<"(0,0)"<<endl; for(j=1;j<i;j++) cout<<"("<<a[j].x<<","<<a[j].y<<")"<<endl; return 0; } /* F:\temp\16139834.54851\Main.cc: In function 'int main()': F:\temp\16139834.54851\Main.cc:26: error: 'qsort' was not declared in this scope */ |
Double click to view unformatted code.