课设
Line.h
#ifndef LINE_H
#define LINE_H
#include"Shape.h"
#include"Point.h"
#include<math.h>
class Line:public Shape{//Ïß
Point p1;
Point p2;
double len;
// static int count;
public:
Line(){}
Line(int a,Point pp1,Point pp2,double l,string b):Shape(a,b),p1(pp1),p2(pp2),len(l){}
Line(const Line& in):Shape(in.Get_obj_id(),in.Get_des()),p1(in.p1),p2(in.p2),len(in.len){}
double Get_len()//È¡ private len
{
return len;
}
float Lenth(){// ¼ÆËãlenth
float lenth2,lenth;
lenth2 = (p2.GetX()-p1.GetX())*(p2.GetX()-p1.GetX())+(p2.GetY()-p1.GetY())*(p2.GetY()-p1.GetY());
lenth = sqrt(lenth2);
return lenth;
}
virtual float Area(){// find lenth£¬Í¬ float Lenth
float lenth2,lenth;
lenth2 = (p2.GetX()-p1.GetX())*(p2.GetX()-p1.GetX())+(p2.GetY()-p1.GetY())*(p2.GetY()-p1.GetY());
lenth = sqrt(lenth2);
return lenth;
}
Line operator=(const Line& in)// =
{
// Line l;
Line l1;
l1.Set_obj_id(in.Get_obj_id());
l1.Set_des(in.Get_des());
// l1.p1.SetX(in.p1.GetX());
// l1.p1.SetY(in.p1.GetY());
// l1.p2.SetX(in.p2.GetX());
// l1.p2.SetY(in.p2.GetY());
p1 = in.p1;
p2 = in.p2;
return l1;
}
friend ostream& operator<<(ostream& out,Line& in);
friend ofstream& operator<<(ofstream& out,Line& in);
friend float Point::Distance_L(Line& in);
bool operator<(const Line& in)//const
{
// Line l;
if(len < in.len) return true;
else return false;
}
bool operator>(const Line& in)//const
{
// Line l;
if(len > in.len) return true;
else return false;
}
void Set_len(double ll)
{
len = ll;
}
void Set_px11(float x1)
{
p1.SetX(x1);
}
void Set_py11(float y1)
{
p1.SetY(y1);
}
void Set_px21(float x2)
{
p2.SetX(x2);
}
void Set_py21(float y2)
{
p2.SetY(y2);
}
float Get_p1x()
{
return p1.GetX();
}
float Get_p1y()
{
return p1.GetY();
}
float Get_p2x()
{
return p2.GetX();
}
float Get_p2y()
{
return p2.GetY();
}
Line FindMAX_Line_Area(Line *l)//3.2 Find max and min Line area
{
Line lmax;
Line lmin;
for(int i = 0; i >= 0; i++)
{
for(int j = 0; j >= 0; j++)
{
if(l[i].Area()>=l[j].Area())
lmax = l[i];
else
lmax = l[j];
}
}
return lmax;
}
Line FindMIN_Line_Area(Line *l)//3.2 Find max and min Line area
{
Line lmax;
Line lmin;
for(int i = 0; i >= 0; i++)
{
for(int j = 0; j >= 0; j++)
{
if(l[i].Area()<=l[j].Area())
lmin = l[i];
else
lmin = l[j];
}
}
return lmin;
}
virtual void WriteToFile(ofstream& o)
{
o<<*this;
// return o;
}//
};
#endif
Line.cpp
#include<fstream>
#include<string>
#include<math.h>
#include"Line.h"
#include<iostream>
using namespace std;
/*
Line Line::operator=(const Line& in)
{
// Line l;
Line l1;
l1.Set_obj_id(in.Get_obj_id());
l1.Set_des(in.Get_des());
l1.p1.SetX(in.p1.GetX());
l1.p1.SetY(in.p1.GetY());
l1.p2.SetX(in.p2.GetX());
l1.p2.SetY(in.p2.GetY());
return l1;
}
*/
ostream& operator<<(ostream& out,Line& l)
{
out<<l.Get_obj_id()<<" "<<l.Get_p1x()<<" "<<l.Get_p1y()<<" "<<l.Get_p2x()<<" "<<l.Get_p2y()<<l.Get_len()<<" "<<l.Get_des()<<endl;
return out;
}
ofstream& operator<<(ofstream& out,Line& l)
{
out<<l.Get_obj_id()<<" "<<l.Get_p1x()<<" "<<l.Get_p1y()<<" "<<l.Get_p2x()<<" "<<l.Get_p2y()<<l.Get_len()<<" "<<l.Get_des()<<endl;
return out;
}
/*
bool Line::operator<(const Line& in)const
{
// Line l;
if(len<in.Area()) return true;
else return false;
}
*/
/*
bool Line::operator>(const Line& in)const
{
// Line l;
if(len>in.Area()) return true;
else return false;
}
*/
//void Line::WriteToFile(ofstream& o,Line& l)
//{
// o<<l.Get_obj_id()<<" "<<l.p1.GetX()<<" "<<l.p1.GetY()<<" "<<l.p2.GetX()<<" "<<l.p2.GetY()<<l.len<<" "<<l.Get_des();
// return o;
//}
Point.h
#ifndef POINT_H
#define POINT_H
#include"Shape.h"
//#include"Rect.h"
#include<string>
#include<fstream>
#include<math.h>
class Rect;
class Line;
class Point:public Shape{//µã
float x,y;
// static int count;
public:
Point(){}
Point(int a,float xx,float yy,string b):Shape(a,b),x(xx),y(yy){}
Point(const Point& in):Shape(in.Get_obj_id(),in.Get_des()),x(in.x),y(in.y){}
// Point operator<<(const Point& in)
// {
// cout<<in.x<<" "<<in.y<<endl;
// }
Point operator=(const Point& in)
{
Point p;
p.Set_obj_id(in.Get_obj_id());
p.Set_des(in.Get_des());
p.SetX(in.x);
p.SetY(in.y);
return p;
}
Point operator+(const Point& in)
{
// float px,py;
// Point p;
x = x+in.x;
y = y+in.y;
return *this;
}
friend ostream& operator<<(ostream& out,Point& in);
friend ofstream& operator<<(ofstream& out,Point& in);
bool operator<(const Point &p)const
{
// Point p1;
if(x < p.x)
{
return true;
}
else if((x == p.x )&&(y < p.y))
{
return true;
}
else
{
return false;
}
}
/* ///operator >
bool operator>(const Point& p)const
{
// Point p1;
if(x > p.x)
{
return true;
}
else if((x == p.x )&&(y > p.y))
{
return true;
}
else
{
return false;
}
}
*/
float Distance(Point& p)
{
//Point p1;
float dis2,dis;
dis2 = (x-p.GetX())*(x-p.GetX())+(y-p.GetY())*(y-p.GetY());
dis = sqrt(dis2);
return dis;
}
float Distance_R(Rect& in);
/* {
float lenth12,lenth22,lenth32,lenth42;
lenth12 = (in.lp.GetX()-x)*(in.lp.GetX()-x)+(in.lp.GetY()-y)*(in.lp.GetY()-y);
lenth22 = (in.rp.GetX()-x)*(in.rp.GetX()-x)+(in.rp.GetY()-y)*(in.rp.GetY()-y);
lenth32 = (in.lp.GetX()-x)*(in.lp.GetX()-x)+(in.rp.GetY()-y)*(in.rp.GetY()-y);
lenth42 = (in.rp.GetX()-x)*(in.rp.GetX()-x)+(in.lp.GetY()-y)*(in.lp.GetY()-y);
if((lenth12<=lenth22)&&(lenth12<=lenth32)&&(lenth12<=lenth42)) return sqrt(lenth12);
else if((lenth22<=lenth12)&&(lenth22<=lenth32)&&(lenth22<=lenth42)) return sqrt(lenth22);
else if((lenth32<=lenth22)&&(lenth32<=lenth12)&&(lenth32<=lenth42)) return sqrt(lenth32);
else if((lenth42<=lenth22)&&(lenth42<=lenth32)&&(lenth42<=lenth12)) return sqrt(lenth42);
}
*/
float Distance_L(Line& in);
float Distance_pp(Point p1,Point p2)
{
float xx1 = p1.GetX();
float yy1 = p1.GetY();
float xx2 = p2.GetX();
float yy2 = p2.GetY();
float d2,d;
d2 = (xx1-xx2)*(xx1-xx2)+(yy1-yy2)*(yy1-yy2);
d = sqrt(d2);
return d;
}
float GetX()
{
return x;
}
float GetY()
{
return y;
}
// void Set_obj_id(int n)
// {
// obj_id = n;
// }
// void Set_des(string s)
// {
// des = s;
// }
void SetX(float xx)
{
x=xx;
}
void SetY(float yy)
{
y=yy;
}
virtual float Area(){return 0;}
virtual void WriteToFile(ofstream& o)
{
o<<*this;
}
};
#endif
Point.cpp
#include"Shape.h"
#include"Point.h"
#include"Rect.h"
#include"Line.h"
#include<iostream>
#include<fstream>
#include<string>
#include<math.h>
using namespace std;
//class Point{
// public:
//float Point Distance_L(Line& in);
//float Point Distance_R(Rect& in);
//};
/*
Point Point::operator=(const Point& in)
{
Point p;
p.Set_obj_id(in.Get_obj_id());
p.Set_des(in.Get_des());
p.SetX(in.x);
p.SetY(in.y);
return p;
}
*/
/*
Point Point::operator+(const Point& in)
{
// float px,py;
// Point p;
x = x+in.x;
y = y+in.y;
return *this;
}
*/
/*
Point::ostream& operator<<(ostream& out,Point& in)//
{
out<<in.GetX()<<" "<<in.GetY();
}
Point::ofstream& operator<<(ofstream& out,Point& in)//
{
out<<in.GetX()<<" "<<in.GetY();
}
*/
/*
bool Point::operator<(const Point& p)const
{
// Point p1;
if(x<p.x) return true;
else if((x==p.x)&&(y<p.y)) return true;
else return false;
}
*/
/*
bool Point::operator>(const Point& p)const
{
// Point p1;
if(x>p.x) return true;
else if((x==p.x)&&(y>p.y)) return true;
else return false;
}
*/
/*
float Point::Distance(Point& p)
{
// Point p1;
float dis2,dis;
dis2 = (x-p.GetX())*(x-p.GetX())+(y-p.GetY())*(y-p.GetY());
dis = sqrt(dis2);
return dis;
}
*/
float Point::Distance_R(Rect& in)//error
{
// Point p1;
float lenth12,lenth22,lenth32,lenth42;
lenth12 = (in.lp.GetX()-x)*(in.lp.GetX()-x)+(in.lp.GetY()-y)*(in.lp.GetY()-y);
lenth22 = (in.rp.GetX()-x)*(in.rp.GetX()-x)+(in.rp.GetY()-y)*(in.rp.GetY()-y);
lenth32 = (in.lp.GetX()-x)*(in.lp.GetX()-x)+(in.rp.GetY()-y)*(in.rp.GetY()-y);
lenth42 = (in.rp.GetX()-x)*(in.rp.GetX()-x)+(in.lp.GetY()-y)*(in.lp.GetY()-y);
if((lenth12<=lenth22)&&(lenth12<=lenth32)&&(lenth12<=lenth42)) return sqrt(lenth12);
else if((lenth22<=lenth12)&&(lenth22<=lenth32)&&(lenth22<=lenth42)) return sqrt(lenth22);
else if((lenth32<=lenth22)&&(lenth32<=lenth12)&&(lenth32<=lenth42)) return sqrt(lenth32);
else if((lenth42<=lenth22)&&(lenth42<=lenth32)&&(lenth42<=lenth12)) return sqrt(lenth42);
}
float Point::Distance_L(Line& in)
{
// Point p;
float k1,k2;
float xp,yp,lenth2;
k1 = (in.p2.GetY()-in.p1.GetY())/(in.p2.GetX()-in.p1.GetX());
k2 = -1/k1;
xp = (in.p2.GetX()+in.p1.GetX())/2;
yp = (in.p2.GetY()+in.p1.GetY())/2;
lenth2 = (xp-x)*(xp-x)+(yp-y)*(yp-y);
return sqrt(lenth2);
}
ostream& operator<<(ostream& out,Point& p)
{
out<<p.Get_obj_id()<<" "<<p.GetX()<<" "<<p.GetY()<<" "<<p.Get_des()<<endl;
return out;
}
ofstream& operator<<(ofstream& out,Point& p)
{
out<<p.Get_obj_id()<<" "<<p.GetX()<<" "<<p.GetY()<<" "<<p.Get_des()<<endl;
return out;
}
//void Point::WriteToFile(ofstream& o,Point& p)
//{
// o<<p.obj_id<<" "<<p.GetX()<<" "<<p.GetY()<<" "<<p.des<<" ";
// return o;
//}
//
Rect.h
#ifndef RECT_H
#define RECT_H
#include"Shape.h"
#include"Point.h"
class Rect:public Shape{//¾ØÐÎ
Point lp;//×óÏÂ
Point rp; //ÓÒÉÏ
// float arear;
// static int count;
public:
Rect(){}
Rect(int a,Point lp1,Point rp1,float rarea,string b):Shape(a,b),lp(lp1),rp(rp1)/*,arear(rarea)*/{}
Rect(const Rect& in):Shape(in.Get_obj_id(),in.Get_des()),lp(in.lp),rp(in.rp)/*,arear(rarea)*/{}
Rect operator=(const Rect& in);
//{
// Rect r1;
// lp=in.lp;
// rp=in.rp;
// return *this;
//}
Rect operator+(const Rect& in);
// {
// Rect r1;
// lp=lp+in.lp;
// rp=rp+in.rp;
// return *this;
// }
bool operator<(const Rect& in)const
{
// Rect r1;
if(Get_des().length() < in.Get_des().length()) return true;
else return false;
}
bool operator>(const Rect& in)const
{
// Rect r1;
if(Get_des().length() > in.Get_des().length()) return true;
else return false;
}
float Distance(Rect& in);
friend ostream& operator<<(ostream& out,Rect& in);
friend ofstream& operator<<(ofstream& out,Rect& in);
friend float Point::Distance_R(Rect& in);
virtual float Area()
{
float area;
area=(rp.GetX()-lp.GetX())*(rp.GetY()-lp.GetY());
return area;
}
void Set_rpx1(float x1)
{
rp.SetX(x1);
}
void Set_rpy1(float y1)
{
rp.SetY(y1);
}
void Set_lpx1(float x2)
{
lp.SetX(x2);
}
void Set_lpy1(float y2)
{
lp.SetY(y2);
}
// void Set_area(float ar)
// {
// arear = ar;
// }
float Get_lpx()
{
return lp.GetX();
}
float Get_lpy()
{
return lp.GetY();
}
float Get_rpx()
{
return rp.GetX();
}
float Get_rpy()
{
return rp.GetY();
}
// float Get_area()
// {
// return arear;
// }
Rect FindMAX_Rect_Area(Rect *r)//3.1 Find max and min Rect area
{
Rect rmax;
Rect rmin;
for(int i = 0; i >= 0; i++)
{
for(int j = 0; j >= 0; j++)
{
if(r[i].Area()>=r[j].Area())
rmax = r[i];
else
rmax = r[j];
}
}
return rmax;
}
Rect FindMIN_Rect_Area(Rect *r)//3.1 Find max and min Rect area
{
Rect rmax;
Rect rmin;
for(int i = 0; i >= 0; i++)
{
for(int j = 0; j >= 0; j++)
{
if(r[i].Area()<=r[j].Area())
rmin = r[i];
else
rmin = r[j];
}
}
return rmin;
}
virtual void WriteToFile(ofstream& o)
{
o<<*this;
// return o;
}//
};
#endif
Rect.cpp
#include"Rect.h"
#include"Point.h"
#include<fstream>
#include<string>
#include<math.h>
#include<iostream>
using namespace std;
//class Rect;
Rect Rect::operator+(const Rect& in)
{
// Rect r1;
lp=lp+in.lp;
rp=rp+in.rp;
return *this;
}
Rect Rect::operator=(const Rect& in)
{
// Rect r1;
lp=in.lp;
rp=in.rp;
return *this;
}
/*
bool Rect::operator<(Rect& in)const
{
// Rect r1;
if(des.length() < in.des.length()) return true;
else return false;
}
bool Rect::operator>(Rect& in)const
{
// Rect r1;
if(des.length() > in.des.length()) return true;
else return false;
}
*/
float Rect::Distance(Rect& in)
{
if((in.lp.GetX() - in.rp.GetX())<(in.rp.GetY() - in.lp.GetY())) return in.lp.GetX() - in.rp.GetX();
else return in.rp.GetY() - in.lp.GetY();
}
ostream& operator<<(ostream& out,Rect& r)
{
out<<r.Get_obj_id()<<" "<<r.Get_lpx()<<" "<<r.Get_lpy()<<" "<<r.Get_rpx()<<" "<<r.Get_rpy()<<" "/*<<r.Get_area()<<" "*/<<r.Get_des()<<endl;
return out;
}
ofstream& operator<<(ofstream& out,Rect& r)//
{
out<<r.Get_obj_id()<<" "<<r.Get_lpx()<<" "<<r.Get_lpy()<<" "<<r.Get_rpx()<<" "<<r.Get_rpy()<<" "/*<<r.Get_area()<<" "*/<<r.Get_des()<<endl;
return out;
}
//void Rect::WriteToFile(ofstream& o,Rect& r)
//{
// o<<r.Get_obj_id()<<" "<<r.lp.GetX()<<" "<<r.lp.GetY()<<" "<<r.rp.GetX()<<" "<<r.rp.GetY()<<" "<<r.Get_des();
// return o;
//}
Shape.h
//#include<iostream>
//using namespace std;
#ifndef SHAPE_H
#define SHAPE_H
#include<string>
//using namespace std;
class Shape{//ÐÎ×´
int obj_id;
string des;
public:
Shape(){}
Shape(int m,string n):obj_id(m),des(n){}
Shape(const Shape& in):obj_id(in.obj_id),des(in.des){}
int Get_obj_id()const{return obj_id;}
string Get_des()const{return des;}
void Set_des(string s)
{
des=s;
}
void Set_obj_id(int n)
{
obj_id=n;
}
virtual float Area() = 0;
// virtual void WriteToFile(ofstream& o) = 0;
};
#endif
main.cpp
#include<iostream>
using namespace std;
#include"Shape.h"
#include"Point.h"
#include"Point.cpp"
#include"Rect.h"
#include"Rect.cpp"
#include"Line.h"
#include"Line.cpp"
#include<fstream>
#include<string>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
template <class T>//2
class List{
T* l;
int size;
public:
List(){}
List(T *lll,int s):l(lll),size(s){}
List(const List& in):l(in.l),size(in.size){}
void FindSameDes(T& t1,T* t2)//2.3
{
for(int j = 0; j >= 0; j++)
{
if(t1.Get_des().lenth() == t2[j].Get_des.lenth())
{
for(int i = 0; i >= 0; i++)
{
if(t2[i].Get_des().find(t1.Get_des()) == 1)
{
cout<<t2[i];
}
}
}
}
}
void FindM_Rect_Area()
{
Rect rmax;
Rect rmin;
for(int i = 0; i >= 0; i++)
{
for(int j = 0; j >= 0; j++)
{
if(l[i].Area()>=l[j].Area())
rmax = l[i];
else
rmax = l[j];
}
}
for(int i = 0; i >= 0; i++)
{
for(int j = 0; j >= 0; j++)
{
if(l[i].Area()<=l[j].Area())
rmin = l[i];
else
rmin = l[j];
}
}
cout<<rmin<<" "<<rmax<<endl;
//fstream dataFile1;
//dataFile1.open("Rect_data.txt",ios::in|ios::out);
//if(dataFile1.fail())
//{
// exit(0);
//}
//dataFile1<<"max:"<<rmax<<" "<<"min:"<<rmin<<endl;
//dataFile1.close();
}
void FindM_Line_Area()
{
Line lmax;
Line lmin;
for(int i = 0; i >= 0; i++)
{
for(int j = 0; j >= 0; j++)
{
if(l[i].Area()>=l[j].Area())
lmax = l[i];
else
lmax = l[j];
}
}
for(int i = 0; i >= 0; i++)
{
for(int j = 0; j >= 0; j++)
{
if(l[i].Area()<=l[j].Area())
lmin = l[i];
else
lmin = l[j];
}
}
// fstream dataFile2;
// dataFile2.open("Line_data.txt");
// dataFile2<<"max:"<<lmax<<" "<<"min:"<<lmin<<endl;
// dataFile2.close();
}
};
int GetCount(Point *p,Line *l,Rect *r)
{
// Point *p;
vector<Point>Pvector;
for(int i = 0; i<=5028; i++)
{
Pvector.push_back(p[i]);
}
vector<Rect>Rvector;
for(int i = 0; i<=4995; i++)
{
Rvector.push_back(r[i]);
}
vector<Line>Lvector;
for(int i = 0; i<=11439; i++)
{
Lvector.push_back(l[i]);
}
Point targetP;
// int sizeP
// int num = count(Pvector.begin(),Pvector.end(),target)
targetP = Pvector.back();
// sizeP = Pvector.size();
Line targetL;
targetL = Lvector.back();
Rect targetR;
targetR = Rvector.back();
int countP = targetP.Get_obj_id();
int countL = targetL.Get_obj_id();
int countR = targetR.Get_obj_id();
return countP+countL+countR;
}
int main()
{
//no error{
fstream PointFile;
fstream LineFile;
fstream RectFile;
PointFile.open("Point.txt",ios::in);
// if(PointFile.fail())
// {
// exit(0);
// }
LineFile.open("Line.txt",ios::in);
// if(LineFile.fail())
// {
// exit(0);
// }
RectFile.open("Rect.txt",ios::in);
// if(RectFile.fail())
// {
// exit(0);
// }
Point *p;//Point.txt
p = new Point [5029];
int nn;
float xx,yy;
//cchar* cc;
string ss;
for(int i = 0; i<=5028; i++)
{
PointFile>>ss;
nn = atoi(ss.data());// char->int
p[i].Set_obj_id(nn);
PointFile>>ss;
xx = atof(ss.data());//char->float
p[i].SetX(xx);
PointFile>>ss;
yy = atof(ss.data());
p[i].SetY(yy);
PointFile>>ss;
//strcpy(ss,cc);
p[i].Set_des(ss.data());
}
//} no error {
Line *ll;
ll = new Line[11439];
int nl;
float x1,x2,y1,y2;
Point lp1,lp2;
string s1;
double len1;
string desl = "NULL";
for(int i = 0; i<=11438; i++)
{
LineFile>>s1;
nl = atoi(s1.data());// char->int
ll[i].Set_obj_id(nl);
LineFile>>s1;
x1 = atof(s1.data());
ll[i].Set_px11(x1);
LineFile>>s1;
y1 = atof(s1.data());
ll[i].Set_py11(y1);
LineFile>>s1;
x2 = atof(s1.data());
ll[i].Set_px21(x2);
LineFile>>s1;
y2 = atof(s1.data());
ll[i].Set_py21(y2);
LineFile>>s1;
len1 = atof(s1.data());
ll[i].Set_len(len1);
ll[i].Set_des(desl);
}
//} no error
Rect *r;
r = new Rect[4995];
int nr;
float lpx1,rpx1,lpy1,rpy1;
string sr;
const char *ch;
float arear;
for(int i = 0; i<=4994; i++)
{
RectFile>>sr;
ch = sr.c_str();
nr = atoi(ch);// char->int
r[i].Set_obj_id(nr);
RectFile>>sr;
ch = sr.c_str();//string->char
lpx1 = atoi(ch);
r[i].Set_lpx1(lpx1);
RectFile>>sr;
ch = sr.c_str();
lpy1 = atoi(ch);
r[i].Set_lpy1(lpy1);
RectFile>>sr;
ch = sr.c_str();
rpx1 = atoi(ch);
r[i].Set_rpx1(rpx1);
RectFile>>sr;
ch = sr.c_str();
rpy1 = atoi(ch);
r[i].Set_rpy1(rpy1);
RectFile>>sr;
ch = sr.c_str();
arear = atof(ch);
// r[i].Set_area(arear);
RectFile>>sr;
r[i].Set_des(sr);
}
//} no error
//
ofstream Rect_data("Rect_data.txt");/find max and min rect area
Rect r_max,rrmax;
Rect r_min,rrmin;
rrmax = r_max.FindMAX_Rect_Area(r);
rrmin = r_min.FindMIN_Rect_Area(r);
rrmax.WriteToFile(Rect_data);
rrmin.WriteToFile(Rect_data);
ofstream Line_data("Line_data.txt");/find amx and min line area
Line l_max,llmax;
Line l_min,llmin;
llmax = l_max.FindMAX_Line_Area(ll);
llmin = l_min.FindMIN_Line_Area(ll);
llmax.WriteToFile(Line_data);
llmin.WriteToFile(Line_data);
//
//
vector<Point>Pvector;
for(int i = 0; i<=5028; i++)
{
Pvector.push_back(p[i]);
}
vector<Rect>Rvector;
for(int i = 0; i<=4995; i++)
{
Rvector.push_back(r[i]);
}
vector<Line>Lvector;
for(int i = 0; i<=11439; i++)
{
Lvector.push_back(ll[i]);
}
Point targetP;
// int sizeP
// int num = count(Pvector.begin(),Pvector.end(),target)
targetP = Pvector.back();
// sizeP = Pvector.size();
Line targetL;
targetL = Lvector.back();
Rect targetR;
targetR = Rvector.back();
int countP = targetP.Get_obj_id();
int countL = targetL.Get_obj_id();
int countR = targetR.Get_obj_id();
//
ofstream Get_Count("Get_Count.txt");
int count;
count = GetCount(p,ll,r);
Get_Count<<count;
ofstream PointIn("Point2.txt");
sort(&p[0],&p[5028]);
for(int i = 0;i <= 5028; i++)
{
p[i].WriteToFile(PointIn);
// p_2[i].WriteToFile(PointIn);
}
Line2
ofstream LineIn("Line2.txt");
// ll[1].WriteToFile(LineIn);
for(int i = 0;i <= 11439; i++)
{
for(int j = 0;j < 11439; j++)
{
float llj = ll[j].Get_len();
float lli = ll[i].Get_len();
if(llj < lli)
{
ll[j].WriteToFile(LineIn);
}
}
}
//
/*/ no used
ofstream PointIn("Point2.txt");
for(int i = 0;i <= 5028; i++)
{
for(int j = 0;j < 5028; j++)
{
if(p[j]<p[i])
{
p[j].WriteToFile(PointIn);
}
}
}
*//
//
Rect2
ofstream RectIn("Rect2.txt");
for(int i = 0;i <= 4994; i++)
{
for(int j = 0;j <= 4994; j++)
{
string s1 = r[j].Get_des();
string s2 = r[i].Get_des();
const char* ch1 = s1.c_str();
const char* ch2 = s2.c_str();
if(strcmp(ch1,ch2) <= 0 )
{
r[j].WriteToFile(RectIn);
}
}
}
//
/* no errer{
Point p1(1,0.0,0.0,"point1");//²âÊÔ¹¦ÄÜ
Point p2(2,2.0,0.0,"point2");
Point p3(3,1.0,0.0,"point3");
Point p4(4,2.0,2.0,"point4");
Point p5(5,3.0,2.0,"point5");
Line l1(6,p1,p2,0.0,"line1");
Rect r1(7,p1,p4,"rect1");
p1.Distance(p2);
cout<<p1.Distance(p2)<<endl;
p3.Distance_L(l1);
cout<<p3.Distance_L(l1)<<endl;
p5.Distance_R(r1);
cout<<p5.Distance_R(r1)<<endl;
Point p6=p1+p2;
cout<<p6<<endl;
if(p1<p2)
{
cout<<"p1<p2"<<endl;
}
else
{
cout<<"p1>=p2"<<endl;
}
if(p3<p2)
{
cout<<"p3<p2"<<endl;
}
else
{
cout<<"p3>=p2"<<endl;
}
Rect r2(8,p4,p5,"rect2");
Rect r3 = r1+r2;
cout<<r3<<endl;
*/}no error
/ T E S T/
// cout<<r[0]<<endl; no error this
// cout<<p[0]<<endl; no error this
// cout<<ll[0]<<endl; no error this
// delete no error
delete []p;
delete []ll;
delete []r;
///
close no error{
PointFile.close();
LineFile.close();
RectFile.close();
PointIn.close();
Get_Count.close();
LineIn.close();
RectIn.close();
Rect_data.close();
Line_data.close();
///
return 0;
}
完整文件包已上传(txt,cpp,h,gch)