Treceți la conținutul principal

matrice cpp

///////////////////////////////////////////////////////////////////////////////////////
//      GONGU MIHAI gr 1051, an3                                        BILET 7      //
//      clasa matrice (pt operatii cu matrice)                                       //
//      vezi enuntul in fisierul text atasat                                         //
///////////////////////////////////////////////////////////////////////////////////////

#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>

class matrice
{private:
     //nr de linii si coloane
     int diml,dimc;
     //pointer la pointer
     //matricea se va aloca dinamic
     double **mat;

 public:
      //pentru generarea matricei nule
      zero();
      //pentru generarea matricei unitate
      unu();
      //constructor de initializare cu zero a tuturor elementelor matricei
      matrice(int nrl,int nrc);
      //constructor de copiere
      matrice(const matrice&);
      //constructor implicit
      matrice();

      //constructor cu preluare de date din fisier
      matrice(char*);

       //destructor
      ~matrice();

      int linii(){return diml;}

      int coloane(){return dimc;}
       //spraicarcarea operatorului +
       matrice &operator+(double a);
       matrice &operator+(matrice a);
       friend matrice operator+(double aa,matrice a);

       //supraincarcarea operatorului -
       matrice &operator-(double a);
       matrice &operator-(matrice a);
       friend matrice operator-(double aa,matrice a);

       //supraincarcarea operatorului *
       matrice &operator*(double a);
       matrice &operator*(matrice a);
       friend matrice operator*(double aa,matrice a);

       //supraincarcarea  operatorului /
       matrice &operator/(double a);
       matrice &operator/(matrice a);
       friend matrice operator/(double aa,matrice a);


       //supraincarcarea operatorilor << si >>
       friend ostream& operator<<(ostream&,matrice);
       friend istream& operator>>(istream&,matrice&);

       //transpunere
       matrice &transp();

       //inversare
       matrice &invers();

       //supraincarcarea lui (double) pt calcularea determinatului
       operator double();

       //rezolvarea matriceala a sistemelor de ecuatii liniare
       void sistem();


       int* operator[](int i);

       int& operator[](int* );
};


 matrice::matrice(int nrl,int nrc)
       {mat=new double*[nrl];

 for(int i=0;i<nrl;i++)
   mat[i]=new double[nrc];

       diml=nrl;
       dimc=nrc;

 for(i=0;i<diml;i++)
   for(int j=0;j<dimc;j++)
      mat[i][j]=0.;
 }
 //******************************************

 matrice::matrice(const matrice &a)
 {int nrl,nrc;
   nrl=a.diml;
          nrc=a.dimc;
   mat=new double*[nrl];
   for(int i=0;i<nrl;i++)
     mat[i]=new double[nrc];

    diml=nrl;
           dimc=nrc;
          for(i=0;i<nrl;i++)
     for(int j=0;j<nrc;j++)
        mat[i][j]=a.mat[i][j];
 }
 //*****************************************

 matrice::matrice()
 {int i,j;
  double **nat;
 cout<<"constructor user"<<endl;
 cout<<endl;
 cout<<"nr de linii=";

 cin>>diml;
 cout<<"nr de coloane=";
 cin>>dimc;
 nat=new double*[diml];
 for(i=0;i<diml;i++)
  nat[i]=new double[dimc];

 for(i=0;i<diml;i++)
   for(j=0;j<dimc;j++)
    {cout<<"a["<<i<<"]["<<j<<"]=";
     cin>>nat[i][j];
    }
 mat=nat;
 }
 //******************************************

 matrice::~matrice()
 {for(int i=0;i<diml;i++)
  delete mat[i];
  delete[] mat;
 }
 //**************************************

 matrice::zero()
 {int i,j;
 cout<<"generarea matricei nule;";
 cout<<endl;
 cout<<"nr de linii="<<endl;
 cin>>diml;
 cout<<"nr de coloane="<<endl;
 cin>>dimc;
 mat=new double*[diml];
 for(i=0;i<diml;i++)
    mat[i]=new double[dimc];

 for(i=0;i<diml;i++)
   for(j=0;j<dimc;j++)
     mat[i][j]=0.;

 cout<<"afisarea matricei nule:";
 for(i=0;i<diml;i++)
   {cout<<endl;
    for(j=0;j<dimc;j++)
      cout<<mat[i][j];
    }
 return 0;
 }
 //***************************************

 matrice::unu()
 {int i,j;
 cout<<"generarea matricei unitate:"<<endl;
 cout<<endl;
 cout<<"introduceti dimensiunea m=";
 cin>>diml;
 dimc=diml;

 mat=new double*[diml];
 for(i=0;i<diml;i++)
     mat[i]=new double[dimc];

 for(i=0;i<diml;i++)
 for(j=0;j<dimc;j++)
    {if(i!=j)mat[i][j]=0;
     else mat[i][j]=1;}
 cout<<"afisare:";
 for(i=0;i<diml;i++)
     {cout<<endl;
      for(j=0;j<dimc;j++)
      cout<<mat[i][j];
     }
 return 0;
 }
 //********************************

       ostream& operator<<(ostream& ies, matrice u)
  {
   int i,j;
   for(i=0;i<u.diml;i++)
     {cout<<endl;
       for(int j=0;j<u.dimc;j++)
        ies<<u.mat[i][j]<<" ";
     };
   return ies;
  }
 //*********************************

       istream& operator>>(istream& intr, matrice& u)
  {int i,m,n,j;
  intr>>u.diml;
  intr>>u.dimc;
  for(i=0;i<u.diml;i++)
   for(j=0;j<u.dimc;j++)
    intr>>u.mat[i][j];
  return intr;
  }
       //***********************************

       matrice &matrice::operator+(double a)
      {
       for(int i=0;i<diml;i++)
  for(int j=0;j<dimc;j++)
    mat[i][j]+=a;
      return *this;
         }
      //************************************

      matrice &matrice::operator-(double a)
      {for(int i=0;i<diml;i++)
  for(int j=0;j<dimc;j++)
    mat[i][j]-=a;
       return *this;
      }
      //************************************

      matrice &matrice::operator*(double a)
      {for(int i=0;i<diml;i++)
  for(int j=0;j<dimc;j++)
    mat[i][j]*=a;
       return *this;
       }
       //***********************************

       matrice &matrice::operator/(double a)
       {for(int i=0;i<diml;i++)
  for(int j=0;j<dimc;j++)
    mat[i][j]/=a;
       return *this;
       }
       //***********************************

       matrice &matrice::operator*(matrice a)
       {double c[10][10];
 int i,j,m,n,p,q,k;
 m=diml;
 n=dimc;
 p=a.diml;
 q=a.dimc;
 if(n!=p)
 {cout<<("matricele nu se pot inmulti");
 getch();
  exit(1);}
 

  for(i=0;i<m;i++)
    for(j=0;j<q;j++)
      {c[i][j]=0.;
       for(k=0;k<n;k++)
       c[i][j]+=mat[i][k] * a.mat[k][j];
       }
 diml=m;
        dimc=q;
 for(i=0;i<diml;i++)
    for(j=0;j<dimc;j++)
             mat[i][j]=c[i][j];
        return *this;

     }

      //************************************


      matrice &matrice::operator+(matrice a)
      {if(diml!=a.diml||dimc!=a.dimc)
       {cout<<"matricele nu se pot aduna!";
 exit(1);
 }
       for(int i=0;i<diml;i++)
  for(int j=0;j<dimc;j++)
    mat[i][j]+=a.mat[i][j];
      return *this;
      }
      //************************************

      matrice &matrice::operator-(matrice a)
      {if(diml!=a.diml||dimc!=a.dimc)
       {cout<<"matricele nu se pot aduna!";
 exit(1);
 }
 for(int i=0;i<diml;i++)
  for(int j=0;j<dimc;j++)
    mat[i][j]-=a.mat[i][j];
      return *this;
      }
      //************************************
                  
      matrice operator+(double aa, matrice a)
      {
      int m,n;
      m=a.diml;
      n=a.dimc;
      matrice p(m,n);
       for(int i=0;i<m;i++)
  for(int j=0;j<n;j++)
    p.mat[i][j]=aa+a.mat[i][j];
       p.diml=m;
       p.dimc=n;
      return p;
      }
      //**************************************

      matrice operator-(double aa, matrice a)
      { 
      int m,n;
      m=a.diml;
      n=a.dimc;
      matrice p(m,n);
       for(int i=0;i<m;i++)
  for(int j=0;j<n;j++)
    p.mat[i][j]=aa-a.mat[i][j];
       p.diml=m;
       p.dimc=n;
      return p;
      }
      //******************************

      matrice operator*(double aa, matrice a)
      { 
      int m,n;
      m=a.diml;
      n=a.dimc;
      matrice p(m,n);
       for(int i=0;i<m;i++)
  for(int j=0;j<n;j++)
    p.mat[i][j]=aa*a.mat[i][j];
       p.diml=m;
       p.dimc=n;
      return p;
      }
      //********************************

      matrice operator/(double aa, matrice a)
      {
      int m,n;
      m=a.diml;
      n=a.dimc;
      matrice p(m,n);
       for(int i=0;i<m;i++)
  for(int j=0;j<n;j++)
    p.mat[i][j]=aa/a.mat[i][j];
       p.diml=m;
       p.dimc=n;
      return p;
      }
      //*******************************

      matrice& matrice::transp()
      {int m,n,i,j;
       double **uu;
       m=diml;n=dimc;
       uu=new double*[n];
       for(i=0;i<n;i++)
   uu[i]=new double[m];

      for(i=0;i<n;i++)
  for(j=0;j<m;j++)
    uu[i][j]=0;
      /*
      for(i=0;i<n;i++)
       {cout<<endl;
       for(j=0;j<m;j++)
   cout<<mat[i][j];
       }*/
      for(i=0;i<n;i++)
  for(j=0;j<m;j++)
    uu[i][j]=mat[j][i];

      diml=n;
      dimc=m;
      //se aloca 
      mat=new double*[diml];
   for(i=0;i<diml;i++)
     mat[i]=new double[dimc];
      //se initializeaza elementele
      for(i=0;i<diml;i++)
  for(j=0;j<dimc;j++)
     mat[i][j]=uu[i][j];

       return *this;
      }
      //**************************************

      matrice &matrice::invers()
      //MENTIUNE:
      //pentru toate functiile de mai jos se va folosi "metoda eliminarii"
      //pentru aflarea inversei, determinantului s.a.m.d.
      ///////////////////////////////////////////
      //pentru algoritmul matematic vezi:
      //"Metode numerice si programe Pascal" de Afrodita Iorgulescu, editura Inforec
      { const eps=0.0001;
 int i,j,k,vb,imax,cod,n;
 double b[10][10],a[10][10],amax,atemp,btemp,d;;

 if(diml!=dimc)
 {
 cout<<"o matrice nepatratica nu poate avea inversa";
  getch();
  exit(1);
 }
  n=diml;
  for(i=0;i<n;i++)
   for(j=0;j<n;j++)
     a[i][j]=mat[i][j];

  //inceputul calculului inversei

     for(i=0;i<=n;i++)
  for(j=0;j<=n;j++)
  if(i==j) b[i][j]=1;
  else b[i][j]=0;
  k=0;
  vb=0;
  do
  {            if(k!=n-1)
         //nu se cauta amax pe ultima coloana
        {amax=abs(a[k][k]);
         int imax=k;

         for(i=k+1;i<n;i++)
     if(amax<abs(a[i][k]))
     {
      amax=abs(a[i][k]);
      imax=i;
     }
         //sfarsitul calcularii lui amax

         if(imax!=k)
     for(j=0;j<n;j++)
       {atemp=a[imax][j];
        a[imax][j]=a[k][j];
        a[k][j]=atemp;

        btemp=b[imax][j];
        b[imax][j]=b[k][j];
        b[k][j]=btemp;
       }
         }//endif
         //in momentul asta imax=k

        if( abs(a[k][k]) <= eps )
     {cod=2;
      vb=1;
     }
       else
       {d=a[k][k];
        for(j=0;j<=n;j++)
     {
     a[k][j]=a[k][j]/d;
     b[k][j]=b[k][j]/d;
     }//impart linia curenta la pivot

        for(i=0;i<n;i++)
          if(i!=k)
      {d=-a[i][k];
       for(j=0;j<=n;j++)

      {
      a[i][j]=a[i][j]+d*a[k][j];
      b[i][j]=b[i][j]+d*b[k][j];
      }

       }
         }
         //sfarsitul lui else
    k=k+1;

    if(k>=n)
      {
      cod=1;
      vb=1;
      }
  }while(vb==0);
  //sfarsitul calculului inversei
         if(cod!=1)
  {cout<<"eroare";
   getch();
   exit(1);}

   for(i=0;i<diml;i++)
     for(j=0;j<dimc;j++)
      mat[i][j]=b[i][j];
    return *this;
    }

          //***********************************

 void matrice::sistem()
 {
 const eps=0.0001;
 int n,cod,k,i,j,imax,vb;
 double a[10][10],b[10],x[10],d,amax,atemp,ap[10][11];
         //cod=1 daca se obtine solutia sistemului x;
         //cod =2 daca nu exista solutie unica; 
         
  if(diml!=dimc)
       {cout<<"trebuia sa fi introdus o matrice patratica!";
        exit(1);
 }

    n=diml;

    for(i=0;i<n;i++)
     for(j=0;j<n;j++)
       a[i][j]=mat[i][j];

   cout<<"introduceti coeficientii vectorului y:"<<endl; 

     for(i=0;i<n;i++)
        {cout<<"b["<<i<<"]=";
        cin>>b[i];
 }

        //inceperea calcularii determinantului
         for(i=0;i<n;i++)
            {for(j=0;j<n;j++)
                ap[i][j]=a[i][j];

             ap[i][n]=b[i]; 
             }//generare matricei extinse ap[][];

          k=0;vb=0;
          do
   {
        if(k!=n-1)
                   {amax=abs(ap[k][k]);
                    imax=k;
                    for(i=k+1;i<n;i++)
             if(amax<abs(ap[i][k]))
      {
      amax=abs(ap[i][k]);
                           imax=i;
                    }
               //sf determinarii amax si imax
                    if(imax!=k)
                for(j=k;j<n+1;j++)
                  {atemp=ap[imax][j];
                   ap[imax][j]=ap[k][j];
                          ap[k][j]=atemp;
                  }
                    }

                 if(abs(ap[k][k])<=eps)
                        {cod=2;
                         vb=1;
          }
                 else
                    {d=ap[k][k];

                     for(j=k;j<n+1;j++)
                          ap[k][j]=ap[k][j]/d;

                     for(i=0;i<n;i++)
                          if(i!=k)
                     {d=-ap[i][k];
                      for(j=k;j<n+1;j++)
                             ap[i][j]=ap[i][j]+d*ap[k][j];
       }

                    }
                 k++;

                if(k>n)
                    {for(i=0;i<n;i++)
             x[i]=ap[i][n];
             cod=1;
             vb=1;
                    }
       }while(vb==0);

   //sfarsitul calcularii efective
    
   if(cod!=1)
     {cout<<"nu exista solutie unica!";
      exit(1);
      }

   else
    {cout<<"solutia sistemului este"<<endl;
     for(i=0;i<n;i++)
       cout
       <<"x["<<i<<"]="<<x[i]<<endl;
     }
   }
   //*****************************************

    matrice::operator double()
  {//calculul determinantului
  const eps=0.0001;
         int cod,n,i,j,k,vb,imax;
  double a[10][10],b[10][10],amax,atemp,btemp,d,delta,t;

        if(diml!=dimc)
  {cout<<"nu se poate calcula determinantul unei matrici nepatratice!"<<endl;
  exit(1);}
         n=diml;
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)  
             a[i][j]=mat[i][j];

         //incepe calcularea determinantului 
         for(i=0;i<=n;i++)
           for(j=0;j<=n;j++)
             if(i==j) b[i][j]=1;
             else b[i][j]=0;
             delta=1;
             k=0;
             vb=0;
          do
          {                  if(k!=n-1)
                              //nu se cauta amax pe ultima coloana 
        {amax=abs(a[k][k]);
                              int imax=k;

                              for(i=k+1;i<n;i++)
                                 if(amax<abs(a[i][k]))
     {
      amax=abs(a[i][k]);
                           imax=i;
                                 }
                              //sfarsitul calcularii lui amax

         if(imax!=k)
                                 {delta=-delta;
                                 for(j=0;j<n;j++)
       {atemp=a[imax][j];
        a[imax][j]=a[k][j];
                                    a[k][j]=atemp;

        btemp=b[imax][j];
                                    b[imax][j]=b[k][j];
        b[k][j]=btemp;
       }
                                  }
                              }//endif
         //in momentul asta imax=k
                                
        if( abs(a[k][k]) <= eps )
                                 {vb=1;
      cout<<"nu exista inversa";
                                  exit(1);
                                 }
                            else
       {
        d=a[k][k];
                             delta*=a[k][k];
                             for(j=0;j<=n;j++)
     {
     a[k][j]=a[k][j]/d;
     b[k][j]=b[k][j]/d;
     }//impart linia curenta la pivot

                             for(i=0;i<n;i++)
                               if(i!=k)
                                  {d=-a[i][k];
       for(j=0;j<=n;j++)
                                          
      {
      a[i][j]=a[i][j]+d*a[k][j];
      b[i][j]=b[i][j]+d*b[k][j];
                                    }

       }
         }   
                              //sfarsitul lui else
                         k=k+1;

    if(k>=n)
                           {t=delta;
       vb=1;
      }
                         else t=0;
             }while(vb==0);
           return t;
             //se termina calculul determinantului

  }
 //****************************************

      matrice &matrice::operator/(matrice a)
 {/*int m,n;
  m=a.diml;
         n=a.dimc;
  matrice p(m,n);
  p=a.invers();
         mat=mat*p;
         return this*;
 */
 return *this;}
        //****************************************


 //*************************************************************************
 //*************************************************************************


void meniu_p()
{clrscr();
 cout<<"****************MENIU***************"<<endl;
 cout<<"1.Introducere si afisare matrice"<<endl;
 cout<<"2.Operatii dintre obiectul curent si o valoare data(double)."<<endl;
 cout<<"3.Operatii dintre doua obiecte."<<endl;
 cout<<"4.Rezolvarea matriceala a sistemelor de ecuatii liniare."<<endl;
 cout<<"5.Transpusa unei matrice;"<<endl;
 cout<<"6.Inversa unei matrice;"<<endl;
 cout<<"7.Determinantul unei matrice (cu conversie cast (double)Matrice;)"<<endl;
 cout<<"8.Determinarea valorilor proprii;"<<endl;
 cout<<"9.Terminare"<<endl;
 }

void meniu_s1()
{clrscr();
 cout<<"1.adunare unei matrice cu un numar real;(comutativate asigurata)"<<endl;
 cout<<"2.inmultirea unei matrice cu un numar real;(comutativitate asigurata)"<<endl;
 cout<<"3.impartirea unei matrice la un numar real;"<<endl;
 cout<<"4.impartirea unui numar real la o matrice;"<<endl;
 cout<<"5.revenire la meniu anterior;"<<endl;
 }

void meniu_s2()
{clrscr();
  cout<<"1.adunarea a doua matrici;"<<endl;
  cout<<"2.scaderea a doua matrici;"<<endl;
  cout<<"3.inmultirea a doua matrici;"<<endl;
  cout<<"4.impartirea a doua matrici;"<<endl;
  cout<<"5.revenire la meniu anterior;"<<endl;}
//****************************************************************
//***************************APELATOR***************************** 
void main()
 {
  label1:clrscr();
      char opt;
      meniu_p();
      cout<<"Introduceti optiunea:";    
      cin>>opt;

      switch(opt)
{/*case 0:clrscr();
 matrice a;
 getch();
        break;*/
 case '1':
       {clrscr();
       matrice a;
       cout<<"Matricea obiect curent este :"<<endl;
       cout<<a;
       getch();
       meniu_p();
       goto label1;
        }
 case '2':
 {label2:
        clrscr();
 char opt1;
        double v;
        meniu_s1();
 cout<<"Introduceti optiunea :";
        cin>>opt1;
 switch(opt1)
 {case '1':
  clrscr();
                matrice i;
  cout<<"Introduceti valoarea reala pe care doriti sa o adunati: "<<endl;
  cin>>v;
                cout<<v;
  cout<<"matricea rezultat este:"<<endl;
  cout<<(i+v);//v+i 
  getch();
  goto label2;
  case '2':
         clrscr();
                matrice b;
  cout<<"Introduceti valoarea reala pe care doriti sa o inmultiti cu matricea:"<<endl;
            cin>>v;
  cout<<"matricea rezultat este:"<<endl;
  cout<<b*v;
  getch();
         goto label2;  
  case '3':
         clrscr();
                matrice c;   
  cout<<"Introduceti valoarea reala la care doriti sa impartiti matricea:"<<endl;
            cin>>v;
  cout<<"matricea rezultat este:"<<endl;
  cout<<c/v;
  cout<<endl;
  getch();
                goto label2; 
  case '4':
         clrscr();
                matrice d; 
  cout<<"Introduceti valoarea reala care se imparte la matrice:"<<endl;
            cin>>v;
  cout<<"matricea rezultat este:"<<endl;
  cout<<v/d;
  getch();
                goto label2; 
  case 5:
  clrscr;
  getch();
                goto label1;
  }goto label1;}
 case '3':
 {label3:
 clrscr();
 char opt2;
        meniu_s2();
 cout<<"Introduceti optiunea :";
        cin>>opt2;
 switch(opt2)
 {case '1':
                {
         clrscr();
  cout<<"prima matrice:"<<endl;
  matrice a;
                cout<<"a doua matrice:"<<endl;
  matrice b;
                cout<<endl;
  cout<<"suma celor doua matrici este:"<<endl;
  cout<<a+b; 
  getch();
  goto label3;} 
  case '2':
                {
         clrscr();
  cout<<"prima matrice:"<<endl;
                matrice c;
                cout<<"a doua matrice:"<<endl;
  matrice d;
                cout<<endl;
  cout<<"diferenta celor doua matrici este:"<<endl;
  cout<<c-d;
  getch();
  goto label3;}
  case '3':
  {
         clrscr();
  cout<<"prima matrice:"<<endl;
                matrice e;
                cout<<"a doua matrice:"<<endl;
  matrice f;
                cout<<endl;
  cout<<"produsul celor doua matrici este:"<<endl;
  cout<<e*f;
  getch();
  goto label3;}
  case '4':
                {
         clrscr();
  cout<<"prima matrice:"<<endl;
                matrice g;
                cout<<"a doua matrice:"<<endl;
  matrice h;
                cout<<endl;
  cout<<"raportul celor doua matrici este:"<<endl;
  cout<<g/h;
  getch();
  goto label3;}
  case '5':goto label1;
  
  }goto label1;}
case '4':
        {
        clrscr();
 cout<<"introduceti matricea coeficientilor:"<<endl;
 matrice i;
        i.sistem();
 getch();
 goto label1;}
case '5':
        {
        clrscr();
        cout<<"introduceti matricea de transpus:"<<endl; 
 matrice j;
 cout<<"transpusa este:"<<endl;
 cout<<j.transp();
 getch();
 goto label1;}
case '6':
        {
 clrscr();
 cout<<endl<<endl<<"ATENTIE!";
 cout<<"deoarece la algoritmul de calcul s-a aplicat metoda"<<endl;
 cout<<"eliminarii, rezultatele pot fi afectatate de matrici"<<endl;
 cout<<"prost conditionate"<<endl;
 cout<<"ex:A= 100  10"<<endl;    
 cout<<"       9.5  1"<<endl;
 cout<<"o matrice prost conditionata se caracterizeaza prin aceea ca"<<endl;
 cout<<"determinantul sau este mai mic in comparatie cu marimea elementelor matricii"<<endl;  
        cout<<endl<<endl<<endl; 
        cout<<"introduceti matricea de inversat:"<<endl;
 matrice k;
 cout<<"inversa este:"<<endl;
 cout<<k.invers();
 getch();
 goto label1;}
case '7':
        {
 clrscr();
   cout<<endl<<endl<<"ATENTIE!";
 cout<<"deoarece la algoritmul de calcul s-a aplicat metoda eliminarii"<<endl;
 cout<<"rezultatele pot fi afectatate de matrici 'prost conditionate'"<<endl;
 cout<<"ex:A= 100  10 "<<endl;    
 cout<<"       9.5  1"<<endl;     
 cout<<"o matrice prost conditionata se caracterizeaza prina aceea ca"<<endl;
 cout<<"determinantul sau este mai mic in comparatie cu marimea elementelor matricii"<<endl;  
        cout<<endl<<endl<<endl;
 cout<<"introduceti matricea pt calculul determinantului"<<endl;
 matrice l;
        cout<<"determinanatul este:"<<endl;
 cout<<(double)l; 
 getch();
 goto label1;}
case '8':
        {
        clrscr();
 cout<<"inca in lucru...";
 getch();
 meniu_p();
        goto label1;}
case '9' :
        {
 cout<<"se iese din program!!!";
 getch();
        break;}
  }
}

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…