Treceți la conținutul principal

polinoame fara template cpp

//Scortariu T. Cristina
//Grupa 1067
//Numar tema (bilet):7

#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <cstdarg>
#include <math.h>

struct elem
 {
 double coef;
 int grad;
 };

const double EPS = 0.001;

class polinom
 {
 elem *pol;
 int nr;

public:

 polinom();
 polinom(int n);
 ~polinom();
 polinom(int k,...);
 
 int grad();
 double coeficient(int g);
 sortare();

 friend ostream &operator <<(ostream&,polinom&);
 friend istream &operator >>(istream&, polinom&);

 
 bool operator!();
 polinom &operator +(polinom&);
 polinom &operator -(polinom&);
 polinom &operator *(polinom&);
 polinom &operator /(polinom&);
 polinom &operator %(polinom&);
 double operator () (double&); 
 polinom &operator --();
 polinom &operator ++();
 polinom &operator +(elem&);
 polinom &operator -(int&);

 double deriv(double&);
 double integ(double&, double&);
 polinom cmMdc(polinom&);
 polinom cmmmc(polinom&);
 double rad ( double&, double& );
 };



//******************************************************************************************//
//------------------------------Constructori si destructori--------------------------------//
//constructor prin introducerea datelor de la terminat
polinom::polinom(int n)
 {
 pol=new elem[n];
 for(int i=nr;i>=0;i--)
  {
  cout<<"\n\t->Coefcientul pentru gradul "<<i<<": ";
  cin>>pol[i].coef;
  pol[i].grad=i;
  }
 }

//constructor implicit
polinom::polinom()
{

}
//destructor
polinom::~polinom()
 {

 } 

//constructor folosind functii cu numarvariabil de argumente 
polinom::polinom(int k,...)
 {
 int c,g,i;
 va_list va;
 va_start( va, k);

 nr=(int)(k/2)-1;

 pol=new elem[nr];

 i=nr;
 while(i >= 0)
 {
  c=va_arg(va, int);
  g=va_arg(va, int);

  pol[i].grad=g;
  pol[i].coef=c;
  i--;
 }
 va_end(va);
 }


//******************************************************************************************//
//--------------------------------------Metode auxiliare--------------------------------//

//aflarea gradului polinomului
polinom::grad()
 {
 return (int)nr;
 }

//alfarea coeficientului unui element dintr-un polinom
double polinom::coeficient(int g)
 {
 double d;
 for(int i=nr;i>=0;i--)
  if(pol[i].grad==g) d=pol[i].coef;
 return (double)d;
 }

//sortarea unui polinom descrescator dupa grad
polinom::sortare()
 {
 int auxgrad;
 double auxcoef;
 for(int i=nr;i>0;i--)
 if (pol[i].grad>pol[i-1].grad) {
         auxgrad=pol[i].grad;
         auxcoef=pol[i].coef;
         pol[i].grad=pol[i-1].grad;
         pol[i].coef=pol[i-1].coef;
         pol[i-1].grad=auxgrad;
         pol[i-1].coef=auxcoef;
         };
    
   }

//******************************************************************************************//
//-------------------------------Supraincarcarea operatorilor << si >>---------------------//

//Operatia de intrare la nivel de obiect
istream &operator >>(istream &is, polinom& p)
 {
 cout<<"Care este gradul polinomului?";
 cin>>p.nr;
 p.pol=new elem[p.nr];
 for(int i=p.nr;i>=0;i--)
  {
  cout<<"\n\t->Coefcientul pentru gradul "<<i<<": ";
  is>>p.pol[i].coef;
  p.pol[i].grad=i;
  };
 return is;
 }
//Operatia de iesire la nivel de obiect
ostream &operator <<(ostream &out,polinom& p)
 {
 for(int i=p.nr;i>=0;i--)
  {if(p.pol[i].grad==0 && p.pol[i].coef!=0) out<<p.pol[i].coef;
  if(p.pol[i].grad==1 && p.pol[i].coef!=0)  out<<p.pol[i].coef<<"X +";
            
  if(p.pol[i].grad>1&& p.pol[i].coef!=0)  out<<p.pol[i].coef<<"X^"<<p.pol[i].grad<<" + ";
            
  };
  if(p.nr==0 && p.pol[0].coef==0) out<<0 ;
 return out;
 }
//******************************************************************************************//
//------------------------Supraincarcarea operatorilor +,-,*,% si / ---------------------//

//Suma a doua polinoame
polinom &polinom::operator +(polinom& p)
 {
 polinom suma;
 int grp=p.grad();
 int grt=this->grad();
 double coefsuma;
 if (grp>=grt) suma.nr=grp;
  else suma.nr=grt;
 suma.pol=new elem[suma.nr+1];
 for(int i=suma.nr;i>=0;i--)
  {
  coefsuma=0;
  if(i<=grp) coefsuma=coefsuma+p.pol[i].coef;
  if(i<=grt) coefsuma=coefsuma+this->pol[i].coef;
  suma.pol[i].grad=i;
  suma.pol[i].coef=coefsuma;
  }
 return suma;
 }

//Diferenta a doua polinoame
polinom &polinom::operator -(polinom& p)
 {
 polinom diferenta;
 int grp=p.grad();
 int grt=this->grad();
 double coefdiferenta;

 if (grp>=grt) diferenta.nr=grp;
 else diferenta.nr=grt; 

 diferenta.pol=new elem[diferenta.nr];
 for(int i=diferenta.nr;i>=0;i--)
  {
  coefdiferenta=0;
  if(i<=grt) coefdiferenta=this->pol[i].coef;
  if(i<=grp) coefdiferenta=coefdiferenta-p.pol[i].coef;
  diferenta.pol[i].grad=i;
  diferenta.pol[i].coef=coefdiferenta;
  };
 int k=diferenta.nr;
 while (k>=0 && diferenta.pol[k].coef==0)
  {
  diferenta.nr=diferenta.nr-1;
  k--;
  }
 if(diferenta.nr<0) diferenta.nr=0;
 
 return diferenta;
 }

//Produsul a doua polinoame
polinom &polinom::operator *(polinom& p)
 {
 polinom produs;
 int grp=p.grad();
 int grt=this->grad();
 produs.nr=grp+grt;
 produs.pol=new elem[produs.nr];

 for(int k=produs.nr;k>=0;k--)
  {produs.pol[k].coef=0;
   produs.pol[k].grad=k;
  }
 for(int i=p.nr;i>=0;i--)
  for(int j=this->nr;j>=0;j--)
   produs.pol[i+j].coef=produs.pol[i+j].coef + p.pol[i].coef * this->pol[j].coef;
    
 return produs;
 }

//Catul rezultat din impartirea a doua polinoame
polinom &polinom::operator /(polinom& p)
 {
 polinom cat;
 polinom aux, deimpartit=(*this);
 polinom temp;

 int grt=deimpartit.grad();
 int grp=p.grad();
 
 cat.nr=grt-grp;
 cat.pol=new elem[cat.nr];
 int k=cat.nr;
 
 while(deimpartit.nr>=p.nr)
 {
 grt=deimpartit.grad();
 cat.pol[k].grad=k;
 cat.pol[k].coef=deimpartit.pol[grt].coef/p.pol[grp].coef;
 aux.pol=new elem[k+1];
 aux.nr=k;
 aux.pol[k].grad=k;
 aux.pol[k].coef=deimpartit.pol[grt].coef/p.pol[grp].coef;
 for(int i=k-1;i>=0;i--)
  {
  aux.pol[i].coef=0;
  aux.pol[i].grad=i;
  };
 temp=aux*p;
 deimpartit=deimpartit-temp;
 k--;
 }

 return cat;
 }


//Restul rezultat din impartirea a doua polinoame
polinom &polinom::operator %(polinom& p)
 {
 polinom cat;
 polinom aux, deimpartit=(*this);
 polinom temp;

 int grt=deimpartit.grad();
 int grp=p.grad();
 
 cat.nr=grt-grp;
 cat.pol=new elem[cat.nr];
 int k=cat.nr;
 
 while(/*deimpartit.nr>=p.nr*/k>=0)
 {
 grt=deimpartit.grad();
 cat.pol[k].grad=k;
 cat.pol[k].coef=deimpartit.pol[grt].coef/p.pol[grp].coef;
 aux.pol=new elem[k+1];
 aux.nr=k;
 aux.pol[k].grad=k;
 aux.pol[k].coef=deimpartit.pol[grt].coef/p.pol[grp].coef;
 for(int i=k-1;i>=0;i--)
  {
  aux.pol[i].coef=0;
  aux.pol[i].grad=i;
  };
 temp=aux*p;
 deimpartit=deimpartit-temp;
 k--;
 }

 return deimpartit;
 }

//******************************************************************************************//
//---------------------Supraincarcarea operatorilor !,--,++,+,- si () ---------------------//

//Test de polinom nul
bool polinom::operator!()
 {
 bool nul;
 nul=0;
 for( int i=nr;i>=0;i--)
  if( pol[i].grad!=0 && pol[i].coef!=0) nul=1;
 return nul;
 }


//Derivare formala
polinom &polinom ::operator -- ()
 {
 polinom derivf;
 derivf.nr=this->nr-1;
 derivf.pol=new elem[derivf.nr];
 for(int i=this->nr;i>0;i--)
  {derivf.pol[i-1].grad=i-1;
  derivf.pol[i-1].coef=this->pol[i].coef*this->pol[i].grad;
  } 
 return derivf;
 }

//Integrare formala
polinom &polinom ::operator ++ ()
 {
 polinom integrf;
 integrf.nr=this->nr+1;
 integrf.pol=new elem[integrf.nr];
 for(int i=this->nr+1;i>0;i--)
  {integrf.pol[i].grad=i;
  integrf.pol[i].coef=this->pol[i-1].coef/(this->pol[i-1].grad+1);
  } 
 integrf.pol[0].grad=0;
 integrf.pol[0].coef=0;
 return integrf;
 }

//Adaugarea unui nou termen
polinom &polinom::operator + (elem &e)
 {
 polinom rezultat;
 double c=e.coef;
 int g=e.grad;
 if(g>this->nr) 
  {
  rezultat.nr=g;
  rezultat.pol=new elem[g];
  rezultat.pol[g].coef=c;
  rezultat.pol[g].grad=g;
  for(int i=g-1;i>=0;i--)
   { if(i>this->nr) { rezultat.pol[i].coef=0; rezultat.pol[i].grad=i; }
     else { rezultat.pol[i].coef=this->pol[i].coef; rezultat.pol[i].grad=i; };
   }
  }
 else 
  {
  rezultat.nr=this->nr;
  rezultat.pol=new elem[rezultat.nr];
  for(int i=this->nr;i>=0;i--)
   {if (i==g) { rezultat.pol[i].coef=this->pol[i].coef+c; rezultat.pol[i].grad=i; }
    else { rezultat.pol[i].coef=this->pol[i].coef; rezultat.pol[i].grad=i; };
   }
  }
 return rezultat;
 }


//Eliminarea unui termen(cheia de identificare a elementului=gradul)
polinom &polinom ::operator - (int& g)
 {
 polinom rez;
 if(g>this->nr) cout<<"Termenul de gradul "<<g<<" nu exista!";
  else 
   {
   rez=(*this);
   rez.pol[g].coef=0;
   int k=rez.nr;
   while (k>=0 && rez.pol[k].coef==0)
    {
    rez.nr=rez.nr-1;
    k--;
    };
   }

 return rez;
 }

//Calcularea valorii polinomului intr-un punct
double polinom::operator() (double &punct)
 {
 double val=0;
 for(int i=this->nr;i>=0;i--)
 {val=val+this->pol[i].coef*pow(punct,(double) this->pol[i].grad);};
 return val;
 }

//********************************************************************************************//
//---Functiile:integ(double,double), deriv(double), cmMdc(), cmmmc(), rad(double, double) ---//

//Evaluarea derivatei intr-un punct folosind operatorii -- si ()
double polinom::deriv(double& pct)
 {
 polinom temp=(*this);
 temp=--temp;
 return temp(pct);
 }

//Integrarea derivatei intr-un punct folosind operatorii ++ si ()
double polinom::integ(double &a, double &b)
 {
 polinom temp=(*this);
 temp=++temp;
 return temp(b)-temp(a);
 }

//Cel mai mare divizor comun a doua polinoame
polinom polinom::cmMdc(polinom &p2)
 {
 polinom p1=(*this);
 if(p2.grad()==0) return p1;
 polinom temp=p1%p2;
 return p2.cmMdc(temp);
 }

//Cel mai mic multiplu comun a doua polinoame
polinom polinom::cmmmc(polinom &p2)
 {
 polinom p1=(*this);
 polinom temp=p1*p2;
 temp=temp/p1.cmMdc(p2);
 return temp;
 }

//Determinarea unei radacinidintr-uninterval dat
double polinom::rad (double& a, double& b)
 {
 double m = (a+b) / 2;
 if ( fabs( a-b) < EPS )
  return m;
 if ( (((*this)(a)) * ((*this)(m))) <= 0 )
  return rad ( a, m );
 else
  return rad ( m, b );
 }


//********************************************************************************************//
//-----------------------------------------Corpul principal ---------------------------------//

void main()

{
 int rasp;
  
 cout<<"----------------------------------Clasa POLINOM--------------------------------"<<endl;
 cout<<"Doriti sa: \n\t-*  1)Introduceti datele de la tastatura \n\t-*  2)Sa folositi datele definite cu ajutorul functiilor cu numar variabil de argumente? \n\t-* 3)Introduceti datele pentru primul polinom, iar al doilea este definit prin functie.";
 cout<<"\nIntroduceti optiunea:";
 cin>>rasp;
 bool ok=false;
 do 
 if(rasp==1)
{
cout<<"\nIntroduceti cele doua polinoame"<<endl;
polinom p1,p2;
cin>>p1;
cin>>p2;
ok=true;
  polinom r;
  double pct, a,b, rez;
  elem e;
  int elim;
  cout<<"-------------------------------------------------------------------------------"<<endl;
  cout<<"\n# Testul de polinom nul";
  if (p1.operator !()==0) cout<<"\n\t\t->>PolinomlP1(x) este nul!";
  else cout<<"\n\t\t->>Polinomul nu este nul!"; 
  if (p2.operator !()==0) cout<<"\n\t\t->>PolinomlP1(x) este nul!";
  else cout<<"\n\t\t->>Polinomul nu este nul!"; 
  cout<<"\n# Suma \n\t->>S(X)=P1(X)+P2(X)="; r=p1+p2; cout<<r<<endl;getch();
  cout<<"\n# Diferenta \n\t->>D(X)=P1(X)-P2(X)="; r=p1-p2; cout<<r<<endl;getch();
  cout<<"\n# Produsul \n\t->>P(X)=P1(X)*P2(X)="; r=p1*p2; cout<<r<<endl;getch();
  cout<<"\n# Catul \n\t->>C(X)=P1(X)/P2(X)="; r=p1/p2; cout<<r<<endl;getch();
  cout<<"\n# Restul \n\t->>R(X)=P1(X)+P2(X)="; r=p1-p2; cout<<r<<endl;getch();
  cout<<"\n# Derivare formala \n\t->>a polinomului P1(X)"; r=--p1; cout<<r<<endl;
   cout<<"\n\t->>a polinomului P2(X)"; r=--p2; cout<<r<<endl;getch();
  cout<<"\n# Integrare formala \n\t->>a polinomului P1(X)"; r=++p1; cout<<r<<endl;getch();
   cout<<"\n\t->>a polinomului P2(X)"; r=++p2; cout<<r<<endl;getch();
  cout<<"\n# Calculul valorii polinomului P1(X) intr-un punct"; 
   cout<<"\n\t->>Introduceti punctul: "; cin>>pct; 
   cout<<"\n\t->>P1("<<pct<<")="; cout<<p2(pct)<<endl;getch();
  cout<<"\n# Adaugarea unui nou termen"; cout<<"\n\t->>Introduceti coeficentul noului element:"; cin>>e.coef;
   cout<<"\n\t->>Introduceti gradul noului element:"; cin>>e.grad; r=p1+e; cout<<"\n\t->>P1(X)="<<r<<endl;getch();
  cout<<"\n# Eliminarea unui termen "; 
   cout<<"\n\t->>Introduceti gradul elementului ce urmeaza a fi eliminat:"; cin>>elim; r=p1-elim; cout<<"\n\t->>P1(X)="<<r<<endl;getch();
 
  cout<<"\n# Integrarea numerica a lui P2(X) pe un interval dat ";
   cout<<"\n\t->>Introduceti limita inferioara:"; cin>>a;
   cout<<"\n\t->>Introduceti limita superioara:"; cin>>b;
   rez=p2.integ(a,b); cout<<rez<<endl; getch();
  cout<<"\n# Calcularea derivatei polinomului P2(X) intr-un punct dat ";
   cout<<"\n\t->>Introduceti punctul:"; cin>>pct; rez=p2.deriv(pct); cout<<rez<<endl;getch();
  cout<<"\n# Calcularea celui mai mare divizor comun:";
   cout<<"\n\t->>cmMdc = "; r=p1.cmMdc(p2);  cout<<r<<endl;getch();
  cout<<"\n# Calcularea celui mai mic multiplu comun:";
   cout<<"\n\t->>cmmmc = "; r=p1.cmmmc(p2);  cout<<r<<endl;getch();
  cout<<"\n# Determinarea unei radacini dintr-un interval dat pentru P1(X):";
   cout<<"\n\t->>Introduceti limita inferioara:"; cin>>a;
   cout<<"\n\t->>Introduceti limita superioara:"; cin>>b;
   rez=p2.rad(a,b); cout<<"\n\t->>Radacina este:"<<rez<<endl;getch();
  cout<<"-------------------------------------------------------------------------------"<<endl; 


}


else if(rasp==2)
{
cout<<"\nPolinoamele sunt:"<<endl;
polinom p1(12,2,5,1,4,-5,3,0,2,-8,1,1,0); 
polinom p2(8,1,3,0,2,0,1,3,0); 
cout<<"P1(X)="<<p1<<endl;
cout<<"P2(X)="<<p2<<endl;
ok=true;
   
 
  polinom r;
  double pct, a,b, rez;
  elem e;
  int elim;
  cout<<"-------------------------------------------------------------------------------"<<endl;
  cout<<"\n# Testul de polinom nul";
  if (p1.operator !()==0) cout<<"\n\t\t->>PolinomlP1(x) este nul!";
  else cout<<"\n\t\t->>Polinomul nu este nul!"; 
  if (p2.operator !()==0) cout<<"\n\t\t->>PolinomlP1(x) este nul!";
  else cout<<"\n\t\t->>Polinomul nu este nul!"; 
  cout<<"\n# Suma \n\t->>S(X)=P1(X)+P2(X)="; r=p1+p2; cout<<r<<endl;getch();
  cout<<"\n# Diferenta \n\t->>D(X)=P1(X)-P2(X)="; r=p1-p2; cout<<r<<endl;getch();
  cout<<"\n# Produsul \n\t->>P(X)=P1(X)*P2(X)="; r=p1*p2; cout<<r<<endl;getch();
  cout<<"\n# Catul \n\t->>C(X)=P1(X)/P2(X)="; r=p1/p2; cout<<r<<endl;getch();
  cout<<"\n# Restul \n\t->>R(X)=P1(X)+P2(X)="; r=p1-p2; cout<<r<<endl;getch();
  cout<<"\n# Derivare formala \n\t->>a polinomului P1(X)"; r=--p1; cout<<r<<endl;
   cout<<"\n\t->>a polinomului P2(X)"; r=--p2; cout<<r<<endl;getch();
  cout<<"\n# Integrare formala \n\t->>a polinomului P1(X)"; r=++p1; cout<<r<<endl;getch();
   cout<<"\n\t->>a polinomului P2(X)"; r=++p2; cout<<r<<endl;getch();
  cout<<"\n# Calculul valorii polinomului P1(X) intr-un punct"; 
   cout<<"\n\t->>Introduceti punctul: "; cin>>pct; 
   cout<<"\n\t->>P1("<<pct<<")="; cout<<p2(pct)<<endl;getch();
  cout<<"\n# Adaugarea unui nou termen"; cout<<"\n\t->>Introduceti coeficentul noului element:"; cin>>e.coef;
   cout<<"\n\t->>Introduceti gradul noului element:"; cin>>e.grad; r=p1+e; cout<<"\n\t->>P1(X)="<<r<<endl;getch();
  cout<<"\n# Eliminarea unui termen "; 
   cout<<"\n\t->>Introduceti gradul elementului ce urmeaza a fi eliminat:"; cin>>elim; r=p1-elim; cout<<"\n\t->>P1(X)="<<r<<endl;getch();
 
  cout<<"\n# Integrarea numerica a lui P2(X) pe un interval dat ";
   cout<<"\n\t->>Introduceti limita inferioara:"; cin>>a;
   cout<<"\n\t->>Introduceti limita superioara:"; cin>>b;
   rez=p2.integ(a,b); cout<<rez<<endl; getch();
  cout<<"\n# Calcularea derivatei polinomului P2(X) intr-un punct dat ";
   cout<<"\n\t->>Introduceti punctul:"; cin>>pct; rez=p2.deriv(pct); cout<<rez<<endl;getch();
  cout<<"\n# Calcularea celui mai mare divizor comun:";
   cout<<"\n\t->>cmMdc = "; r=p1.cmMdc(p2);  cout<<r<<endl;getch();
  cout<<"\n# Calcularea celui mai mic multiplu comun:";
   cout<<"\n\t->>cmmmc = "; r=p1.cmmmc(p2);  cout<<r<<endl;getch();
  cout<<"\n# Determinarea unei radacini dintr-un interval dat pentru P1(X):";
   cout<<"\n\t->>Introduceti limita inferioara:"; cin>>a;
   cout<<"\n\t->>Introduceti limita superioara:"; cin>>b;
   rez=p2.rad(a,b); cout<<"\n\t->>Radacina este:"<<rez<<endl;getch();
  cout<<"-------------------------------------------------------------------------------"<<endl; 


}


else if(rasp==3)
{
polinom p1;
cout<<"\nIntroduceti datele pentru primul polinom"<<endl;
cin>>p1; 
polinom p2(4,-19,1,19,0);
cout<<"P1(x)="<<p1<<endl;
cout<<"P2(x)="<<p2<<endl;
ok=true;

 polinom r;
  double pct, a,b, rez;
  elem e;
  int elim;
  cout<<"-------------------------------------------------------------------------------"<<endl;
  cout<<"\n# Testul de polinom nul";
  if (p1.operator !()==0) cout<<"\n\t\t->>PolinomlP1(x) este nul!";
  else cout<<"\n\t\t->>Polinomul nu este nul!"; 
  if (p2.operator !()==0) cout<<"\n\t\t->>PolinomlP1(x) este nul!";
  else cout<<"\n\t\t->>Polinomul nu este nul!"; 
  cout<<"\n# Suma \n\t->>S(X)=P1(X)+P2(X)="; r=p1+p2; cout<<r<<endl;getch();
  cout<<"\n# Diferenta \n\t->>D(X)=P1(X)-P2(X)="; r=p1-p2; cout<<r<<endl;getch();
  cout<<"\n# Produsul \n\t->>P(X)=P1(X)*P2(X)="; r=p1*p2; cout<<r<<endl;getch();
  cout<<"\n# Catul \n\t->>C(X)=P1(X)/P2(X)="; r=p1/p2; cout<<r<<endl;getch();
  cout<<"\n# Restul \n\t->>R(X)=P1(X)+P2(X)="; r=p1-p2; cout<<r<<endl;getch();
  cout<<"\n# Derivare formala \n\t->>a polinomului P1(X)"; r=--p1; cout<<r<<endl;
   cout<<"\n\t->>a polinomului P2(X)"; r=--p2; cout<<r<<endl;getch();
  cout<<"\n# Integrare formala \n\t->>a polinomului P1(X)"; r=++p1; cout<<r<<endl;getch();
   cout<<"\n\t->>a polinomului P2(X)"; r=++p2; cout<<r<<endl;getch();
  cout<<"\n# Calculul valorii polinomului P1(X) intr-un punct"; 
   cout<<"\n\t->>Introduceti punctul: "; cin>>pct; 
   cout<<"\n\t->>P1("<<pct<<")="; cout<<p2(pct)<<endl;getch();
  cout<<"\n# Adaugarea unui nou termen"; cout<<"\n\t->>Introduceti coeficentul noului element:"; cin>>e.coef;
   cout<<"\n\t->>Introduceti gradul noului element:"; cin>>e.grad; r=p1+e; cout<<"\n\t->>P1(X)="<<r<<endl;getch();
  cout<<"\n# Eliminarea unui termen "; 
   cout<<"\n\t->>Introduceti gradul elementului ce urmeaza a fi eliminat:"; cin>>elim; r=p1-elim; cout<<"\n\t->>P1(X)="<<r<<endl;getch();
 
  cout<<"\n# Integrarea numerica a lui P2(X) pe un interval dat ";
   cout<<"\n\t->>Introduceti limita inferioara:"; cin>>a;
   cout<<"\n\t->>Introduceti limita superioara:"; cin>>b;
   rez=p2.integ(a,b); cout<<rez<<endl; getch();
  cout<<"\n# Calcularea derivatei polinomului P2(X) intr-un punct dat ";
   cout<<"\n\t->>Introduceti punctul:"; cin>>pct; rez=p2.deriv(pct); cout<<rez<<endl;getch();
  cout<<"\n# Calcularea celui mai mare divizor comun:";
   cout<<"\n\t->>cmMdc = "; r=p1.cmMdc(p2);  cout<<r<<endl;getch();
  cout<<"\n# Calcularea celui mai mic multiplu comun:";
   cout<<"\n\t->>cmmmc = "; r=p1.cmmmc(p2);  cout<<r<<endl;getch();
  cout<<"\n# Determinarea unei radacini dintr-un interval dat pentru P1(X):";
   cout<<"\n\t->>Introduceti limita inferioara:"; cin>>a;
   cout<<"\n\t->>Introduceti limita superioara:"; cin>>b;
   rez=p2.rad(a,b); cout<<"\n\t->>Radacina este:"<<rez<<endl;getch();
  cout<<"-------------------------------------------------------------------------------"<<endl; 




}


  else {cout<<"\n Optiunea aleasa nu este admisa. Alegeti 1, 2 sau 3.";}
 
 while(!ok);

 
}

Comentarii

Postări populare de pe acest blog

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='+'…

NUMERE PRIME ALGORITM C++

// NUMERE PRIME ALGORITM C++//  reediting from scratch //on this page is just the study for a next algoritm for generating the parime nr series like Fibonnaci or ....if possibile
BPN = 2 POW 74207281 -1

odd impar
even par

!!! any even number is a sum of two even numbers or two odd numbers or two prime numbers
!!! any odd number is a sum of a odd number and a even numbers
!!!  prime numbers can not be a sum of two prime numbers but will be a sum of a prime number and an even number 
!!! any prime numbers will be odd too but not all odd number are primes
!!! all the numbers formed by same digit  1,3,7,9 are not prime numbers except 11


0, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 
37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 
79, 83, 89, 97

1 = 1 + 0+ 0              0
2 = 1 + 1+ 0              1
3 = 2 + 1+ 0              1

small numbers 

5 = 3 + 2+ 0              2
7 = 5 + 2 + 0              2
11 = 7 + 3 + 1            4
13 = 11+2 + 0            2
17 = 13 + 3 + 1 4
19 = 17 + 2+ 0 2
23 = 19 + 3 + 1 4
29 = 23 + 5 + …

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…