Treceți la conținutul principal

punct cpp

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define PI 3.14159
#include<stdlib.h>
class PUNCT
{
public:
  double x ,y;
  PUNCT(double xx, double yy)
  {
   x=xx;
   y=yy;
  }
  PUNCT()
  {
   x=0;
   y=0;
  }
  int operator ==(PUNCT a)
  {
   if ((x==a.x)&&(y==a.y))
    return 1;
   return 0;
  }
  friend ostream& operator <<(ostream &, PUNCT);
  friend istream& operator >>(istream &, PUNCT &);
};

ostream& operator <<(ostream & iesire, PUNCT p)
{
 iesire<<"\nOx= "<<p.x<<" "<<"\nOy= "<<p.y<<" "<<endl;
 return iesire;
}
istream& operator >>(istream & intrare, PUNCT &p)
{
 cout<<"\nOx= ";
 intrare>>p.x;
 cout<<"\nOy= ";
 intrare>>p.y;
 return intrare;
}

class FIG_GEOM
{
public:
 int n;
 PUNCT p[100];
 FIG_GEOM(int nr, PUNCT pp[100])
 {
  int i;
  n=nr;
  for(i=0;i<nr;i++)
   p[i]=pp[i];
 }
 FIG_GEOM(int nn)
 {
  n=nn;
 }
 friend FIG_GEOM* operator+(PUNCT,FIG_GEOM);
 friend FIG_GEOM* operator-(FIG_GEOM);
 virtual double Aria();
 virtual double Perimetru();
 friend int In_Triunghi(PUNCT,PUNCT,PUNCT,PUNCT);
 virtual int Apartine(PUNCT a);
 double operator &(FIG_GEOM);
 virtual PUNCT ** Intersect(PUNCT a,PUNCT b);
 virtual FIG_GEOM* Aflare_dreptunghi();
 friend double Latura(PUNCT,PUNCT);
 friend PUNCT ** Punct_Comun(PUNCT,PUNCT,PUNCT,PUNCT);
 friend double operator |(FIG_GEOM,FIG_GEOM);
 friend double operator -(FIG_GEOM,FIG_GEOM);

};



class Dreptunghi:public FIG_GEOM
{ 
public:
 Dreptunghi(PUNCT a, PUNCT b):FIG_GEOM(4)
 {
  p[0].x=a.x;
  p[0].y=a.y;
  p[1].x=b.x;
  p[1].y=a.y;
  p[2].x=b.x;
  p[2].y=b.y;
  p[3].x=a.x;
  p[3].y=b.y;
 }
 double Perimetru()
 {
  return 2*((p[2].x-p[0].x)+(p[2].y-p[0].y));
 }
 double Aria()
 {
  return((p[2].x-p[0].x)*(p[2].y-p[0].y));
 }
 FIG_GEOM *Aflare_dreptunghi()
 {
   return this;
 }
};

class Cerc:public FIG_GEOM
{
public:
 Cerc(PUNCT a, PUNCT b):FIG_GEOM(2)
 {
  p[0].x=a.x;
  p[0].y=a.y;
  p[1].x=b.x;
  p[1].y=b.y;
 }
 double Lungime_Cerc()
 {
  return ((p[1].x-p[0].x)*PI);
 }
 double Aria()
 {
  return ((p[1].x-p[0].x)*(p[1].x-p[0].x))*PI/4;
 }
 FIG_GEOM* Aflare_dreptunghi()
 {
  Dreptunghi *drept;
  double l;
  l=(p[1].x-p[0].x)/2;
  PUNCT a(p[0].x,p[0].y-l),  b(p[1].x,p[1].y+l);
  drept=new Dreptunghi(a,b);
  return drept;
 }
 operator Dreptunghi()
 {
  Dreptunghi *drept;
  double l;
  l=(p[1].x-p[0].x)/2;
  PUNCT a(p[0].x,p[0].y-l),  b(p[1].x,p[1].y+l);
  drept=new Dreptunghi(a,b);
  return *drept; 
 }

};
class Triunghi:public FIG_GEOM
{
public:
 Triunghi(PUNCT a, PUNCT b,PUNCT c):FIG_GEOM(3)
 {
  p[0].x=a.x;
  p[0].y=a.y;
  p[1].x=b.x;
  p[1].y=b.y;
  p[2].x=c.x;
  p[2].y=c.y;
 }
 friend double Latura(PUNCT,PUNCT);
 friend double Aria(PUNCT,PUNCT,PUNCT);
 double Perimetru()
 {
  return (Latura(p[0],p[1])+ Latura(p[1],p[2])+ Latura(p[2],p[0]));
 }
 double Aria()
 {
  return ::Aria(p[0],p[1],p[2]);
 }
};
double Latura(PUNCT a, PUNCT b)
{
 return sqrt((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y));
}

double Aria(PUNCT a, PUNCT b, PUNCT c)
{
 double sper;
 Triunghi t(a,b,c);
 sper=(t.Perimetru())/2;
 if((sper<=Latura(a,b))&&(sper<=Latura(b,c))&&(sper<=Latura(c,a)))
  return 0.0;
 double ariat=sper*(sper-Latura(a,b))*(sper-Latura(b,c))*(sper-Latura(c,a));
 return sqrt(ariat);
}

class Trapez:public FIG_GEOM
{
public:
 Trapez(PUNCT a, PUNCT b,PUNCT c, PUNCT d):FIG_GEOM(4)
 {
  p[0].x=a.x;
  p[0].y=a.y;
  p[1].x=b.x;
  p[1].y=b.y;
  p[2].x=c.x;
  p[2].y=c.y;
  p[3].x=d.x;
  p[3].y=d.y;
 }
// Trapez(PUNCT pp[4]):FIG_GEOM(4)
 double Perimetru()
 {
  return (Latura(p[0],p[1])+Latura(p[1],p[2])+Latura(p[2],p[3])+Latura(p[3],p[0]));
 }
 double Aria()
 {
  return (::Aria(p[0],p[1],p[2])+ ::Aria(p[2],p[3],p[0]));
 }
};
FIG_GEOM* operator+(PUNCT a, FIG_GEOM figura)
 {
 int nrp=(figura.n)+1;
 PUNCT pp[100];
 for(int i=0;i<figura.n;i++)
  pp[i]=figura.p[i];
 pp[nrp-1]=a;
 FIG_GEOM *noua=new FIG_GEOM(nrp,pp);
 return noua;
}
FIG_GEOM* operator-(FIG_GEOM figura)
{
 int nrp=(figura.n)-1;
 PUNCT pp[100];
 for(int i=0;i<nrp;i++)
  pp[i]=figura.p[i];;
 FIG_GEOM *noua=new FIG_GEOM(nrp,pp);
 return noua;
}
double FIG_GEOM::Perimetru()
{
 double per=0;
 for(int i=0;i<n-1;i++)
  per=per+Latura(p[i],p[i+1]);
 per=per+Latura(p[n-1],p[0]);
 return per;
}
double FIG_GEOM::Aria()
{
 double aria=0;
 for(int i=0;i<n-2;i++)
  aria=aria+::Aria(p[0],p[i+1],p[i+2]);
 return aria;
}
FIG_GEOM* FIG_GEOM::Aflare_dreptunghi()
{
 PUNCT z,t;
 Dreptunghi *drept;
 int i;
 z=p[0];
 t=p[0];
 for(i=1;i<=n-1;i++)
 {
  if(p[i].x<z.x)
   z.x=p[i].x;
 }
 for(i=1;i<=n-1;i++)
 {
  if(p[i].y<z.y)
   z.y=p[i].y;
 }
 for(i=1;i<=n-1;i++)
 {
  if(p[i].x>t.x)
   t.x=p[i].x;
 }
 for(i=1;i<=n-1;i++)
 {
  if(p[i].y>t.y)
   t.y=p[i].y;
 }
 drept=new Dreptunghi(z,t);
 return drept;
}

int In_Triunghi(PUNCT a, PUNCT b, PUNCT c, PUNCT d)
{
 if ((Aria(a,b,c)<=Aria(a,b,d)+Aria(a,d,c)+Aria(b,d,c)+0.2)&&
  (Aria(a,b,c)>=Aria(a,b,d)+Aria(a,d,c)+Aria(b,d,c)-0.2))
  return 1;
 else return 0;
}
int FIG_GEOM::Apartine(PUNCT a)
{
 for(int i=0;i<n-2;i++)
  if(In_Triunghi(p[0],p[i+1],p[i+2],a))
   return 1;
 return 0;
}
int Pe_Dreapta(PUNCT a,PUNCT b,PUNCT c)  //c se afla intre a si b pe dreapta ab;poate fi si a
{ 
 double m;
 int vb=0;
 m=(a.x*b.y+a.y*c.x+b.x*c.y-c.x*b.y-c.y*a.x-b.x*a.y);  
 //din determiantul (x y 1/ x1 y1 1/ x2 y2 1)=0;
 //daca pc(x,y) e pe dr ...
 if((m==0)&&(c.x>=a.x)&&(c.x<=b.x)&&(c.y>=a.y)&&(c.y<=b.y)) vb=1;
 if((m==0)&&(c.x<=a.x)&&(c.x>=b.x)&&(c.y<=a.y)&&(c.y>=b.y)) vb=1;
 return vb;
}

//vede si daca ambele puncte sunt comune,sau numai unul este
PUNCT ** Punct_Comun(PUNCT a,PUNCT b,PUNCT c,PUNCT d)
{
 int vb=0;
 PUNCT **rez=new PUNCT*[2];
 PUNCT *rez1=new PUNCT;
 PUNCT *rez2=new PUNCT;
 if(Pe_Dreapta(a,b,c)) 
 { 
  *rez1=c; vb=1;
 }
 if(Pe_Dreapta(a,b,d)) 
 {
  *rez2=d; vb=1;
 }
 if(Pe_Dreapta(c,d,a)) 
 {
  *rez1=a; vb=1;
 }
 if(Pe_Dreapta(c,d,b)) 
 {
  *rez2=b; vb=1;
 }
 if((vb==0)&&(a.x==b.x)&&(c.x==d.x)) 
 {
  delete rez1;
  delete rez2;
  *rez=NULL;
  return rez;
 }
 if((vb==0)&&(a.x!=b.x)&&(c.x!=d.x))    
  //daca nu sunt perpend. pe Ox
 { 
  double pc;
  double m=(b.y-a.y)/(b.x-a.x);
  double n=(c.y-d.y)/(c.x-d.x);
  if(m!=n) 
  { 
   //din eq dreptei y-y1=m*(x-x1)
   pc=(m*a.x+a.y-n*c.x+c.y)/(m-n);//x-ul pc de intersectie
             //trebuie sa fie intre cele doua puncte
   if(((pc>a.x)&&(pc<b.x))||((pc<a.x)&&(pc>b.x)))
   {
    rez1->x=pc;
    rez1->y=a.y+m*(rez1->x-a.x);
    if (rez2) delete rez2;
    rez[0]=rez2;    
    rez[1]=NULL;
    return rez;;
   }
  }
  else 
  {
   delete rez1;
   delete rez2;
   rez[0]=rez[1]=NULL;;
   return rez;;
  }
 }
 if((a.x==b.x)&&(c.x!=d.x)&&(((c.x<a.x)&&(d.x>a.x))||((c.x>a.x)&&(d.x<a.x)))&&(((c.y>a.y)&&(c.y<b.y))||((c.y>b.y)&&(c.y<a.y))))
 {
  rez1->x=a.x;
  rez1->y=c.y+(d.y-c.y)*(rez1->x-c.x)/(d.x-c.x);
  delete rez2;
  rez[0]=rez1;
  rez[1]=NULL;
  return rez;;
 }
 
 if((c.x==d.x)&&(a.x!=b.x)&&(((a.x<c.x)&&(b.x>c.x))||((a.x>c.x)&&(b.x<c.x)))&&(((c.y<a.y)&&(a.y<d.y))||((a.y>d.y)&&(c.y>a.y))))
 {
  rez1->x=c.x;
  rez1->y=a.y+(b.y-a.y)*(rez1->x-a.x)/(b.x-a.x);
  delete rez2;
  rez[0]=rez1;
  rez[1]=NULL;
  return rez;
 }
 rez[1]=rez[0]=NULL;
 return rez;
}
PUNCT ** FIG_GEOM::Intersect(PUNCT a,PUNCT b)
{ 
 PUNCT **rez1=new PUNCT*[2];
 PUNCT **rez2=new PUNCT*[2];
 for(int i=0;i<n-1;i++)
 {
   rez1=Punct_Comun(a,b,p[i],p[i+1]);
  if (rez1[0])
   if (rez1[1])
    return rez1;
   else
   {
    for (int j=i+1;j<n-1;j++)
    {
     rez2=Punct_Comun(a,b,p[j],p[j+1]);
     if (rez2[0])
     {
      rez1[1]=rez2[0];
      return rez1;
     }
    }
    rez2=Punct_Comun(a,b,p[n-1],p[0]);
    if (rez2[0])
    {
     rez1[1]=rez2[0];
     return rez1;
    }
    return rez1;
   }
 }
 rez1=Punct_Comun(a,b,p[n-1],p[0]);
 return rez1;
}
double FIG_GEOM::operator &(FIG_GEOM figura2)
{
 FIG_GEOM figura3(0);
 PUNCT **pintersect1=new PUNCT*[2];
 PUNCT **pintersect2=new PUNCT*[2];
 int vb=0,i,j;

 // daca fig1 este inclusa in fig2, cu tot cu intersectii de laturi
 for (i=0;i<n-1;i++)
 {
  if (figura2.Apartine(p[i]))
  {
   for(j=0;j<figura3.n;j++)
    if(p[i]==figura3.p[j])
     vb=1;
   if(!vb)
   {
   figura3.p[figura3.n]=p[i];
   figura3.n++;
   }
  }
  pintersect1=figura2.Intersect(p[i], p[i+1]);
  if (pintersect1[0])
  {
   figura3.p[figura3.n].x=pintersect1[0]->x;
   figura3.p[figura3.n].y=pintersect1[0]->y;
   figura3.n++;
   if (pintersect1[1]!=NULL)
   {
    figura3.p[figura3.n].x=pintersect1[1]->x;
    figura3.p[figura3.n].y=pintersect1[1]->y;
    figura3.n++;
   }
  }
 }
 // ultimul punct daca apartine
  if (figura2.Apartine(p[n-1]))
  {
   figura3.p[figura3.n]=p[n-1];
   figura3.n++;
  }

 //ulitma latura daca se intersecteaza
  pintersect1=figura2.Intersect(p[n-1], p[0]);
  if (pintersect1[0])
  {
   figura3.p[figura3.n].x=pintersect1[0]->x;
   figura3.p[figura3.n].y=pintersect1[0]->y;
   figura3.n++;
   if (pintersect1[1]!=NULL)
   {
    figura3.p[figura3.n].x=pintersect1[1]->x;
    figura3.p[figura3.n].y=pintersect1[1]->y;
    figura3.n++;
   }
  }
 // cautam daca fig2 inclus in fig1, numai cu varfuri
 for (i=0;i<figura2.n;i++)
 {
  if (Apartine(figura2.p[i]))
  {
   for(j=0;j<figura3.n;j++)
    if(figura3.p[j]==figura2.p[i])
     vb=1;
    if(!vb)
    {
    figura3.p[figura3.n]=figura2.p[i];
    figura3.n++;
    }
  }
 }
 return figura3.Aria();
}

double operator|(FIG_GEOM figura1,FIG_GEOM figura2)
{
 double ar1=figura1.Aria();
 double ar2=figura2.Aria();
 return (ar1+ar2-(figura1&figura2));
}
double operator-(FIG_GEOM figura1,FIG_GEOM figura2)
{
 return (figura1.Aria()-(figura1&figura2));
}
void meniu_principal()
{
 system("cls");
 cout<<"\n              MENIU\n\n\n";
 cout<<"\n 1.  Operatii pe o figura";
 cout<<"\n 2.  Operatii pe doua figuri";
 cout<<"\n 0.  Iesire";

}

void meniu_una()
{
 //system("cls");
 cout<<"         \n\nOPERATII PE O FIGURA\n\n\n";
 cout<<"\n 1.  Figura oarecare";
 cout<<"\n 2.  Cerc";
 cout<<"\n 3.  Dreptunghi";
 cout<<"\n 4.  Triunghi";
 cout<<"\n 5.  Trapez";
 cout<<"\n 6.  Adaugare punct la o figura";
 cout<<"\n 7.  Eliminare punct din figura";
 cout<<"\n 0.  Iesire";
 
}
void meniu_doua()
{
 //system("cls");
 
 cout<<"\n\n";
 cout<<"              OPERATII PE DOUA FIGURI\n";
 cout<<"                   INTERSECTII\n\n";
 cout<<"\n 1.  Dreptunghi - Dreptunghi ";
 cout<<"\n 2.  Dreptunghi - Triunghi";
 cout<<"\n 3.  Dreptunghi - Trapez";
 cout<<"\n 4.  Triunghi - Trapez";
 cout<<"\n 0.  Iesire";
}



void main(void)
{
 int nrp,vb;
 PUNCT a,b,c,d,e;
 PUNCT pp[100];
 double rez;
 
 meniu_principal();
 int opt;
 cout<<"\n\nIntroduceti optiunea:";
 cin>>opt;
 while(opt!=0)
 {
  switch(opt)
  {
  case 1:
   {
    meniu_una();
    int ales;
    cout<<"\nIntroduceti operatia pentru o figura:";
    cin>>ales;
    while(ales!=0)
    {
     switch(ales)
     {
     case 1:
      {   
       system("cls");
       cout<<"\nOperatii pe fig. oarecare";
       cout<<"\nDati nr de puncte al figurii: ";
       cin>>nrp;
       while(nrp<3)
       {
        cout<<"\nFigura trebuie sa aiba cel putin 3 puncte";
        cout<<"\nReintroduceti numarul de puncte: ";
        cin>>nrp;
       }
       cout<<"\nCoordonatele punctelor:";
       for(int i=0;i<nrp;i++)
       {
        cout<<"\nPunctul "<<i;
        cin>>pp[i];
       }
       FIG_GEOM *fig=new FIG_GEOM(nrp,pp);
       FIG_GEOM *Aflare_dreptunghi=new FIG_GEOM(4);
       Aflare_dreptunghi=fig->Aflare_dreptunghi();
       cout<<"\nIncadrare in dreptunghiul:"<<Aflare_dreptunghi->p[0]<<Aflare_dreptunghi->p[2];
       cout<<"\nAria: "<<fig->Aria();
       cout<<"\nPerimetrul: "<<fig->Perimetru();
       cout<<"\n";
       meniu_una();
       break;
      }
     case 2:
      {
       system("cls");
       cout<<"\nOperatii pe cerc";
       cout<<"\nSe dau 2 puncte -> paralela cu Ox";
       cout<<"\nEle reprezinta diametrul";
       cout<<"\nDati punctele";
       vb=0;
       while(vb==0)
       {
        cout<<"\nPentru primul punct:";
        cin>>a;
        cout<<"\nPentru al doilea punct:";
        cin>>b;
        if(a.y==b.y) vb=1;
        else cout<<"\nReintroduceti(nu e o dreapta paralela):";
       }
       Cerc *cerc=new Cerc(a,b);
       cout<<"\nLungimea cercului(perimetrul) este:"<<cerc->Lungime_Cerc();
       cout<<"\nAria este:"<<cerc->Aria();
       FIG_GEOM *Aflare_dreptunghi=new FIG_GEOM(4);
       Aflare_dreptunghi=cerc->Aflare_dreptunghi();
       cout<<"\nIncadrare in patratul:"<<Aflare_dreptunghi->p[0]<<Aflare_dreptunghi->p[2];
       Dreptunghi dr2=(Dreptunghi)(*cerc);
       cout<<"\nAria acestui patrat:"<<dr2.Aria();
       meniu_una();
       break;
      }
     case 3:
      {
       system("cls");
       cout<<"\nOperatii pe dreptunghi";
       cout<<"\nSe dau punctele ce descriu diagonala patratului(cele doua capete)";
       cout<<"\nDati punctele";
       cout<<"\nPentru primul punct:";
       cin>>a;
       cout<<"\nPentru al doilea punct:";
       cin>>b;
       Dreptunghi *dreptunghi=new Dreptunghi(a,b);
       cout<<"\nPerimetrul:"<<dreptunghi->Perimetru();
       cout<<"\nAria:"<<dreptunghi->Aria();       
       meniu_una();
       break;
      }
     case 4:
      {
       system("cls");
       cout<<"\nOperatii pe triunghi";
       cout<<"\nSe introduc cele 3 puncte";
       cout<<"\nPentru primul punct:";
       cin>>a;
       cout<<"\nPentru al doilea punct:";
       cin>>b;
       cout<<"\nPentru al treilea punct:";
       cin>>c;
       Triunghi *triunghi=new Triunghi(a,b,c);
       cout<<"\nPerimetrul:"<<triunghi->Perimetru();
       cout<<"\nAria:"<<triunghi->Aria();
       FIG_GEOM *Aflare_dreptunghi=new FIG_GEOM(4);
       FIG_GEOM *test=new FIG_GEOM(3);
       test=triunghi;
       Aflare_dreptunghi=test->Aflare_dreptunghi();
       cout<<"\nIncadrare in dreptunghiul:"<<Aflare_dreptunghi->p[0]<<Aflare_dreptunghi->p[2];
       meniu_una();
       break; 
      }
     case 5:
      {
       system("cls");
       cout<<"\nOperatii pe trapez";
       cout<<"\nSe introduc dreptele paralele cu Ox";
       cout<<"\nPrima dreapta";
       vb=0;
       while(vb==0)
       {
        cout<<"\nPrimul punct:";
        cin>>a;
        cout<<"\nAl doilea punct:";
        cin>>b;
        if(a.y!=b.y) {vb=0;cout<<"\nDreapta nu este paralela cu Ox.\nReintroduceti:";}
        if(a.y==b.y) vb=1;
       }
       cout<<"\nA doua dreapta";
       vb=0;
       while(vb==0)
       {
        cout<<"\nPrimul punct:";
        cin>>c;
        cout<<"\nAl doilea punct:";
        cin>>d;
        if(c.y!=d.y) {vb=0;cout<<"\nDreapta nu este paralela cu Ox.\nReintroduceti:";}
        if(c.y==d.y) vb=1;
       }
       Trapez *trapez=new Trapez(a,b,c,d);
       cout<<"\nPerimetrul este "<<trapez->Perimetru();
       cout<<"\nAria este "<<trapez->Aria();
       FIG_GEOM *Aflare_dreptunghi=new FIG_GEOM(4);
       Aflare_dreptunghi=trapez->Aflare_dreptunghi();
       cout<<"\nIncadrare in dreptunghiul:"<<Aflare_dreptunghi->p[0]<<Aflare_dreptunghi->p[2];
       meniu_una();
       break;
      }
     case 6:
      {
       system("cls");
       cout<<"Adaugare punct la o figura";
       cout<<"\nDati nr de puncte al figurii: ";
       cin>>nrp;
       while(nrp<3)
       {
        cout<<"\nFigura trebuie sa aiba cel putin 3 puncte";
        cout<<"\nReintroduceti numarul de puncte: ";
        cin>>nrp;
       }
       cout<<"\nCoordonatele punctelor:";
       for(int i=0;i<nrp;i++)
       {
        cout<<"\nPunctul "<<i;
        cin>>pp[i];
       }
       FIG_GEOM *fig=new FIG_GEOM(nrp,pp);
       cout<<"\nAria: "<<fig->Aria();
       cout<<"\nPerimetrul: "<<fig->Perimetru();
       cout<<"\n";
       cout<<"\nPunctele din care a fost alcatuita figura au fost:";
       for(i=0;i<nrp;i++)
       {
        cout<<"\nPunctul "<<i;
        cout<<pp[i];
       }
       cout<<"\nDati coordonatele unui punct in plus";
       cout<<"\nVa fi adaugat dupa ultimul punct deja existent";
       cin>>a;
       while(fig->Apartine(a)) 
       {
        cout<<"\nPoligon concav!\nReintroduceti:";
        cin>>a;
       }
       FIG_GEOM *fig1=(a+*fig);
       cout<<"\nAcum figura are punctele: ";
       for(i=0;i<(*fig1).n;i++)
       {
        cout<<"\nPunctul "<<i;
        cout<<(*fig1).p[i];
       }
       cout<<"\nNoua Arie: "<<fig1->Aria();
       cout<<"\nNoul Perimetru: "<<fig1->Perimetru();
       meniu_una();
       break;
      }
     case 7:
      {
       system("cls");
       cout<<"\nDati nr de puncte al figurii: ";
       cin>>nrp;
       while(nrp<4)
       {
        cout<<"\nFigura trebuie sa aiba cel putin 4 puncte pentru ";
        cout<<"\na putea elimina unul din ele.";
        cout<<"\nReintroduceti numarul de puncte: ";
        cin>>nrp;
       }
       cout<<"\nCoordonatele punctelor:";
       for(int i=0;i<nrp;i++)
       {
        cout<<"\nPunctul "<<i;
        cin>>pp[i];
       }
       FIG_GEOM *fig=new FIG_GEOM(nrp,pp);
       cout<<"\nAria: "<<fig->Aria();
       cout<<"\nPerimetrul: "<<fig->Perimetru();   
       cout<<"\nEliminare punct din figura";
       cout<<"\nVa fi eliminat ultimul punct";
       FIG_GEOM *fig1=-(*fig);
       cout<<"\nAcum figura are punctele: ";
       for(i=0;i<nrp-1;i++)
       {
        cout<<"\nPunctul "<<i;
        cout<<pp[i];
       }
       cout<<"\nNoua arie: "<<fig1->Aria();
       cout<<"\nNoul perimetru: "<<fig1->Perimetru();
       meniu_una();
       break;
      } 
     default:{cout<<"\nReintroduceti:";break;}
     }
     cout<<"\nIntroduceti operatia pentru o figura:";
     cin>>ales;
    }
    break;
   }
  case 2:
   {
    system("cls");
    meniu_doua();
    int ales;
    cout<<"\n\n Introduceti optiunea pentru doua figuri:";
    cin>>ales;
    if((ales==0)||(ales>4)) break;
    while(ales!=0)
    {
     switch(ales)
     {
     case 1:
      {
       system("cls");
       cout<<"\nCoordonatele primului dreptunghi ";
       cout<<"\nSe dau punctele de pe diagonala dreptunghiului";
       cout<<"\nDati punctele";
       cout<<"\nPentru primul punct:";
       cin>>a;
       cout<<"\nPentru al doilea punct:";
       cin>>b;
       Dreptunghi *dreptunghi1=new Dreptunghi(a,b);
       cout<<"\nCoordonatele celui de al doilea dreptunghi "; 
       cout<<"\nSe dau punctele de pe diagonala dreptunghiului";
       cout<<"\nDati punctele";
       cout<<"\nPentru primul punct:";
       cin>>c;
       cout<<"\nPentru al doilea punct:";
       cin>>d;
       Dreptunghi *dreptunghi2=new Dreptunghi(c,d);
       rez=*dreptunghi1&*dreptunghi2;
       cout<<"\nSuprafata comuna: "<<rez;
       cout<<"\nSuprafata totala ocupata de figuri: "<<dreptunghi1->Aria()+dreptunghi2->Aria()-rez;
       cout<<"\nFigura 1 fara figura 2: "<<dreptunghi1->Aria()-rez;      
       meniu_doua();
       break;
      }
     case 2:
      {
       system("cls");
       cout<<"\nCoordonatele dreptunghiului ";
       cout<<"\nSe dau punctele de pe diagonala dreptunghiului";
       cout<<"\nDati punctele";
       cout<<"\nPentru primul punct:";
       cin>>a;
       cout<<"\nPentru al doilea punct:";
       cin>>b;
       Dreptunghi *dreptunghi=new Dreptunghi(a,b);
       cout<<"\nCoordonatele triunghiului ";
       cout<<"\nDati primul punct:";
       cin>>c;
       cout<<"\nAl doilea punct:";
       cin>>d;
       cout<<"Al treilea punct:";
       cin>>e;
       Triunghi *triunghi=new Triunghi(c,d,e);
       rez=*dreptunghi&*triunghi;
       cout<<"\nSuprafata comuna: "<<rez;
       cout<<"\nSuprafata totala ocupata de figuri: "<<dreptunghi->Aria()+triunghi->Aria()-rez;
       cout<<"\nFigura 1 fara figura 2: "<<dreptunghi->Aria()-rez;
       meniu_doua();
       break;
      }
     case 3:
      {
       system("cls");
       cout<<"\nCoordonatele dreptunghiului ";
       cout<<"\nSe dau punctele de pe diagonala dreptunghiului";
       cout<<"\nDati punctele";
       cout<<"\nPentru primul punct:";
       cin>>a;
       cout<<"\nPentru al doilea punct:";
       cin>>b;
       Dreptunghi *dreptunghi=new Dreptunghi(a,b);
       cout<<"\nPentru trapez:";
       cout<<"\nSe introduc dreptele paralele cu Ox";
       cout<<"\nPrima dreapta";
       vb=0;
       while(vb==0)
       {
        cout<<"\nPrimul punct:";
        cin>>a;
        cout<<"\nAl doilea punct:";
        cin>>b;
        if(a.y!=b.y) {vb=0;cout<<"\nDreapta nu este paralela cu Ox.\nReintroduceti:";}
        if(a.y==b.y) vb=1;
       }
       cout<<"\nA doua dreapta";
       vb=0;
       while(vb==0)
       {
        cout<<"\nPrimul punct:";
        cin>>c;
        cout<<"\nAl doilea punct:";
        cin>>d;
        if(c.y!=d.y) {vb=0;cout<<"\nDreapta nu este paralela cu Ox.\nReintroduceti:";}
        if(c.y==d.y) vb=1;
       }
       Trapez *trapez=new Trapez(a,b,c,d);
       rez=*dreptunghi&*trapez;
       cout<<"\nSuprafata comuna: "<<rez;
       cout<<"\nSuprafata totala ocupata de figuri: "<<dreptunghi->Aria()+trapez->Aria()-rez;
       cout<<"\nFigura 1 fara figura 2: "<<dreptunghi->Aria()-rez;
       meniu_doua();
       break;
      }
     case 4:
      {
       system("cls");
       cout<<"\nCoordonatele triunghiului:";
       cout<<"\nPentru primul punct:";
       cin>>a;
       cout<<"\nPentru al doilea punct:";
       cin>>b;
       cout<<"\nPentru al treilea punct:";
       cin>>c;
       Triunghi *triunghi=new Triunghi(a,b,c);
       cout<<"\nPentru trapez:";
       cout<<"\nSe introduc dreptele paralele cu Ox";
       cout<<"\nPrima dreapta";
       vb=0;
       while(vb==0)
       {
        cout<<"\nPrimul punct:";
        cin>>a;
        cout<<"\nAl doilea punct:";
        cin>>b;
        if(a.y!=b.y) {vb=0;cout<<"\nDreapta nu este paralela cu Ox.\nReintroduceti:";}
        if(a.y==b.y) vb=1;
       }
       cout<<"\nA doua dreapta";
       vb=0;
       while(vb==0)
       {
        cout<<"\nPrimul punct:";
        cin>>c;
        cout<<"\nAl doilea punct:";
        cin>>d;
        if(c.y!=d.y) {vb=0;cout<<"\nDreapta nu este paralela cu Ox.\nReintroduceti:";}
        if(c.y==d.y) vb=1;
       }
       Trapez *trapez=new Trapez(a,b,c,d);
       rez=*triunghi&*trapez;
       cout<<"\nSuprafata comuna: "<<rez;
       cout<<"\nSuprafata totala ocupata de figuri: "<<triunghi->Aria()+trapez->Aria()-rez;
       cout<<"\nFigura 1 fara figura 2: "<<triunghi->Aria()-rez;
       meniu_doua();
       break;       
      }
     default: {cout<<"\nReintroduceti";break;}
     }
     cout<<"\n\n Introduceti optiunea pentru doua figuri:";
     cin>>ales;
    }
    meniu_doua();
    break;
   }
  default:{cout<<"\nReintroduceti:";break;}
  }
  meniu_principal();
  cout<<"\nIntroduceti optiunea:";
  cin>>opt;
 }

}

Comentarii

Postări populare de pe acest blog

WINDOWS 10 COMPUTER FREEZING PROBLEM SOLVED

good news : a BIOS UPDATE can resolve the problem but just for a Windows 7 on 64 bits o.s. and the system is not stable all the time. even after  bios update the system can freeze.
new info : u can try to low the screen brightness and see if this error appear so often after 
news: last info !!! maybe a virus. scann our system now with an antivirus i generate this error using other device ( a tablet pc) connected in the same network and the laptop i have this problem just freeze  http://thehackernews.com/2013/10/backdoor-found-in-chinese-tenda.html

news : if u use a tenda router this make couse all this problems



what i discover so far :
1.the electric company have many failure and affect the main ISP router/switch for building  also the router/switch installed by the ISP may be affected by overheating and will crash after a long utilisation on heat conditions 2.the router/switch of ISP affect any router of the user between this router and pc/laptop of client 3.the router and any other device of t…

program principal cpp

#include "clasa.h" #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> #define DELAY 9000000 void delay() { for(long i=0;i<DELAY;i++); } //constructor cu initializare de la tastatura BigInt::BigInt() {char x; signed char t[400]; int i; printf("\nNumarul cu semn "); do s=getche(); while((s!='+')&&(s!='-')); n=0; do {x=getche(); t[n]=x-'0'; n++; } while((x>='0')&&(x<='9')); n--; for(i=0;i<n;i++) nr[i]=t[n-i-1]; } //constructor cu initializare prin parametri BigInt::BigInt(char semn,signed char numar[],int dim) {int i; s=semn; n=dim; for(i=0;i<n;i++) nr[i]=numar[n-i-1]; } //transform un int negativ in pozitiv int BigInt::Pozitiv(int x) {int a,vb; a=0; vb=0; while(vb==0) if((x+a)==0) vb=1; else a=a+1; x=a; return x; } //constructor dintr-un nr int obisnuit BigInt::BigInt(int x) {int i; if(x>=0) s='+'…

o aplicatie php localitati romania

//APLICATIA SE REFERA LA BAZA DE DATE SIRUTA

//dragtable.js


/* dragtable v1.0 June 26, 2008 Dan Vanderkam, http://danvk.org/dragtable/ http://code.google.com/p/dragtable/ \Bsortabledraggable\B Instructions: - Download this file - Add <script src="dragtable.js"></script> to your HTML. - Add class="draggable" to any table you might like to reorder. - Drag the headers around to reorder them. This is code was based on: - Stuart Langridge's SortTable (kryogenix.org/code/browser/sorttable) - Mike Hall's draggable class (http://www.brainjar.com/dhtml/drag/) - A discussion of permuting table columns on comp.lang.javascript Licensed under the MIT license. */ // Here's the notice from Mike Hall's draggable script: //***************************************************************************** // Do not remove this notice. // // Copyright 2001 by Mike Hall. // See http…