|
|
back to boardCommon BoardWhy do I get message "COMPILATION ERROR"??? I compiled my program on Borland C++Builder 5 compiler and it works. Posted by Quinn 5 Mar 2002 14:23 Why do I get message "COMPILATION ERROR"??? I compiled my program on Borland C++Builder 5 compiler and it works. Here is the source of the program (solving problem 1046): #include <stdio.h> #include <math.h> typedef unsigned short index; #define MAXPOINTS 50 struct Tpoint { double x,y; }; struct Tvertice { double x,y,a; }; class Tpolygon { public: index n; Tvertice v[MAXPOINTS]; Tpoint rotatebyv(Tpoint,index); }; class Tsearcher { private: Tpolygon*p; int inited; Tpoint c; double pr; public: Tsearcher(Tpolygon*); void init(double); int ensearch(void); Tpoint getpoint(void); }; int main(void) { index i; double f; Tpolygon p; Tsearcher s(&p); scanf("%hu",&p.n); for (i=0; i<p.n; i++) { scanf("%lf",&f); p.v[i].x=f; scanf("%lf",&f); p.v[i].y=f; } for (i=0; i<p.n; i++) { scanf("%lf",&f); p.v[i].a=f; } s.init(1e-3); while (!s.ensearch()); Tpoint c=s.getpoint(); for (i=0; i<p.n; i++) { printf("%.0lf %.0lf\n",c.x,c.y); c=p.rotatebyv(c,i); } return(0); } Tpoint Tpolygon::rotatebyv(Tpoint p,index i) { Tpoint np; double a=v[i].a*M_PI/180; p.x-=v[i].x; p.y-=v[i].y; np.x=p.x*cos(a)-p.y*sin(a); np.y=p.x*sin(a)+p.y*cos(a); np.x+=v[i].x; np.y+=v[i].y; return(np); } Tsearcher::Tsearcher(Tpolygon*P) { p=P; inited=0; } void Tsearcher::init(double PR) { pr=PR; c.x=0; c.y=0; inited=1; } int Tsearcher::ensearch(void) { index i; Tpoint l=c,d; for (i=0; i<p->n; i++) c=p->rotatebyv(c,i); c.x=(l.x+c.x)/2; c.y=(l.y+c.y)/2; d.x=fabs(l.x-c.x); d.y=fabs(l.y-c.y); if ((d.x<pr)&&(d.y<pr)) return(1); else return(0); } Tpoint Tsearcher::getpoint(void) { return(c); } |
|
|