begin process at 2012 02 12 13:21:46
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Maths & Algorithmes

 > UNE MATRICE CREUSE EN TURBOC

UNE MATRICE CREUSE EN TURBOC


 Information sur la source

Note :
1 / 10 - par 1 personne
1,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Maths & Algorithmes Classé sous :Matrice creuse, liste chainée, langage c, benhsain, emsi Niveau :Débutant Date de création :07/02/2002 Date de mise à jour :05/12/2007 08:37:26 Vu / téléchargé :6 968 / 260

Auteur : hamdan

Ecrire un message privé
Site perso
Commentaire sur cette source (4)
Ajouter un commentaire et/ou une note

 Description

c'est un prg qui pesente une matrice creuse dans la memoir( matrice creurse +75% =0)
en utilisant les classes
Compilateur TurboC 3.0 sous windows

Source

  • #include<dos.h>
  • #include<conio.h>
  • #include<iostream.h>
  • #include<stdlib.h>
  • class element
  • {
  • public:
  • element(int=1,int=1,int=1);
  • int ligne(element*x){return x->lig;}
  • int colonne(element*x){return x->col;}
  • int valeur(element*x){return x->val;}
  • void afctacol_suiv(element *x,element*y){x->col_suiv=y;}
  • void afctalig_suiv(element *x,element*y){x->lig_suiv=y;}
  • element *rtncol_suiv(element*x){return x->col_suiv;}
  • element *rtnlig_suiv(element*x){return x->lig_suiv;}
  • void operator delete(void *p){delete p;}
  • private:
  • int lig,col,val;
  • element* col_suiv,*lig_suiv;
  • };
  • class Matrix:public element
  • {
  • public:
  • ~Matrix();
  • Matrix(int=0,int=0);
  • void afficher();
  • void lecture(int,int,int);
  • int extraire(int,int);
  • Matrix operator+(Matrix);
  • Matrix operator*(Matrix);
  • private:
  • int nbr_col,nbr_lig;
  • element *T_col[10],*T_lig[10];
  • };
  • void alarma()
  • {
  • unsigned frequence;
  • do
  • {
  • for(frequence=500 ; frequence<=1500; frequence+=50)
  • {
  • sound(frequence);
  • delay(10);
  • }
  • for(frequence=1500; frequence>=500; frequence-=50)
  • {
  • sound(frequence);
  • delay(10);
  • }
  • }
  • while(! kbhit());
  • nosound();
  • }
  • char menu_prince()
  • {
  • char c;
  • textcolor(14);
  • clrscr();
  • cout<<" MENU PRINCIPAL \n";
  • gotoxy(1,10);
  • cout<<" 1 )-------- Lecture\n";
  • cout<<" 2 )-------- Extraction\n";
  • cout<<" 3 )-------- Affichage\n";
  • cout<<" 4 )-------- Addition\n";
  • cout<<" 5 )-------- Multiplication\n";
  • cout<<" 6 )-------- Quitter\n";
  • gotoxy(1,10);textcolor(10+BLINK);cprintf(" 1");
  • gotoxy(1,11);textcolor(11+BLINK);cprintf(" 2");
  • gotoxy(1,12);textcolor(12+BLINK);cprintf(" 3");
  • gotoxy(1,13);textcolor(10+BLINK);cprintf(" 4");
  • gotoxy(1,14);textcolor(11+BLINK);cprintf(" 5");
  • gotoxy(1,15);textcolor(12+BLINK);cprintf(" 6");
  • gotoxy(79,24);
  • textcolor(14);
  • c=getch();
  • clrscr();
  • return c;
  • }
  • char menu_lecture()
  • {
  • char c;
  • textcolor(14);
  • clrscr();
  • cout<<" LECTURE \n";
  • gotoxy(1,10);
  • cout<<"1 )-------- Rempilissage de La Matrix 1 \n";
  • cout<<"2 )-------- Rempilissage de La Matrix 2\n";
  • cout<<"3 )-------- Retour\n";
  • gotoxy(1,10);textcolor(10+BLINK);cprintf("1");
  • gotoxy(1,11);textcolor(11+BLINK);cprintf("2");
  • gotoxy(1,12);textcolor(12+BLINK);cprintf("3");
  • gotoxy(79,24);
  • textcolor(14);
  • c=getch();
  • clrscr();
  • return c;
  • }
  • char menu_extraire()
  • {
  • char c;
  • textcolor(14);
  • clrscr();
  • cout<<" EXTRAIRE \n";
  • gotoxy(1,10);
  • cout<<"1 )-------- Extaire de La Matrix 1 \n";
  • cout<<"2 )-------- Extaire de La Matrix 2\n";
  • cout<<"3 )-------- Retour\n";
  • gotoxy(1,10);textcolor(10+BLINK);cprintf("1");
  • gotoxy(1,11);textcolor(11+BLINK);cprintf("2");
  • gotoxy(1,12);textcolor(12+BLINK);cprintf("3");
  • gotoxy(79,24);
  • textcolor(14);
  • c=getch();
  • clrscr();
  • return c;
  • }
  • char menu_affichage()
  • {
  • char c;
  • clrscr();
  • cout<<" AFFICHAGE \n";
  • gotoxy (1,10);
  • cout<<"1 )-------- Afficher La Matrix 1\n";
  • cout<<"2 )-------- Afficher La Matrix 2 \n";
  • cout<<"3 )-------- Afficher La Matrix Resultat \n";
  • cout<<"4 )-------- Retour\n";
  • gotoxy(1,10);textcolor(10+BLINK);cprintf("1");
  • gotoxy(1,11);textcolor(11+BLINK);cprintf("2");
  • gotoxy(1,12);textcolor(11+BLINK);cprintf("3");
  • gotoxy(1,13);textcolor(12+BLINK);cprintf("4");
  • gotoxy(79,24);
  • textcolor(14);
  • c=getch();
  • clrscr();
  • return c;
  • }
  • /**/
  • element::element(int x,int y,int z)
  • {
  • lig=x;
  • col=y;
  • val=z;
  • col_suiv=NULL;
  • lig_suiv=NULL;
  • }
  • /**/
  • Matrix::~Matrix()
  • {
  • delete(*T_col);
  • delete(*T_lig);
  • }
  • /**/
  • Matrix::Matrix(int x, int y)
  • { int i;
  • char c;
  • int init_nbr_col,init_nbr_lig;
  • nbr_lig=x;
  • nbr_col=y;
  • //initialisation du tableau colonne par NULL
  • // La partie colonnes
  • for(i=1;i<=y;i++)
  • T_col[i]=NULL;
  • // La partie lignes
  • for(i=1;i<=x;i++)
  • T_lig[i]=NULL;
  • }
  • /**/
  • void Matrix::afficher()
  • {
  • element *ptr;
  • int i,j,x,y;
  • for(j=1;j<=nbr_lig;j++)
  • for(i=1;i<=nbr_col;i++)
  • {
  • gotoxy(i*3,j*3);
  • cout<<"0";
  • }
  • for(i=1;i<=nbr_col;i++)
  • {
  • ptr=T_col[i];
  • while(ptr!=NULL)
  • {
  • y=ligne(ptr);
  • x=colonne(ptr);
  • gotoxy(x*3,y*3);
  • cout<<valeur(ptr);
  • ptr=rtncol_suiv(ptr);
  • }
  • }
  • getch();
  • }
  • /**/
  • int Matrix::extraire(int x,int y)
  • { int ind_lig,ind_col;
  • element *ptr1,n;
  • ptr1=T_col[y];
  • if(ptr1)
  • {
  • ind_lig=n.ligne(ptr1);
  • while((ptr1)&&(ind_lig!=x))
  • {
  • ptr1=n.rtncol_suiv(ptr1);
  • ind_lig=n.ligne(ptr1);
  • }
  • }
  • if(ptr1)return n.valeur(ptr1);
  • else return 0;
  • }
  • /**/
  • void Matrix::lecture(int lig,int col,int val)
  • {
  • int ind_col,ind_lig;
  • element *ptrn,*ptr1,*ptr2;
  • element elem;
  • if(lig&&col&&val)//Pour creer un new noeud il faut tester si
  • //col!=0 et val!=0 et lig!=0
  • {
  • ptrn=new element(lig,col,val);
  • ptr1=T_col[col];//un attachement
  • ptr2=ptr1;//sauvgarde
  • if(ptr1)
  • {
  • ind_lig=elem.ligne(ptr1);
  • if(ind_lig>elem.ligne(ptrn))
  • {
  • T_col[col]=ptrn;
  • elem.afctacol_suiv(ptrn,ptr1);
  • }
  • else
  • {
  • while((ptr1)&&(ind_lig<(elem.ligne(ptrn))))
  • {
  • ptr2=ptr1;
  • ptr1=elem.rtncol_suiv(ptr1);
  • ind_lig=elem.ligne(ptr1);
  • }
  • if(ind_lig==elem.ligne(ptrn))
  • {
  • elem.afctacol_suiv(ptrn,elem.rtncol_suiv(ptr1));
  • if(ptr1==T_col[col])
  • T_col[col]=ptrn;
  • else elem.afctacol_suiv(ptr2,ptrn);
  • }
  • else
  • {
  • elem.afctacol_suiv(ptrn,elem.rtncol_suiv(ptr2));
  • elem.afctacol_suiv(ptr2,ptrn);
  • }
  • }
  • }
  • else
  • T_col[col]=ptrn;
  • ptr1=T_lig[lig];
  • ptr2=ptr1;
  • if(ptr1)
  • {
  • ind_col=elem.colonne(ptr1);
  • if(ind_col>elem.colonne(ptrn))
  • {
  • T_lig[lig]=ptrn;
  • elem.afctalig_suiv(ptrn,ptr1);
  • }
  • else
  • {
  • while((ptr1)&&(ind_col<(elem.colonne(ptrn))))
  • {
  • ptr2=ptr1;
  • ptr1=elem.rtnlig_suiv(ptr1);
  • ind_col=elem.colonne(ptr1);
  • }
  • }
  • if(ind_col==elem.colonne(ptrn))
  • {
  • elem.afctalig_suiv(ptrn,elem.rtncol_suiv(ptr1));
  • if(ptr1==T_lig[lig])
  • T_lig[lig]=ptrn;
  • else elem.afctalig_suiv(ptr2,ptrn);
  • }
  • else
  • {
  • elem.afctalig_suiv(ptrn,elem.rtncol_suiv(ptr2));
  • elem.afctalig_suiv(ptr2,ptrn);
  • }
  • }
  • else
  • T_lig[lig]=ptrn;
  • }
  • }
  • /**/
  • Matrix Matrix::operator+(Matrix mat2)
  • {
  • Matrix m3(nbr_col,nbr_lig);
  • int i,j,z,w;
  • if((nbr_col==mat2.nbr_col)&&(nbr_lig==mat2.nbr_lig))
  • {
  • for(i=1;i<=nbr_lig;i++)
  • for(j=1;j<=nbr_col;j++)
  • {
  • z=extraire(i,j);
  • w=mat2.extraire(i,j);
  • m3.lecture(i,j,z+w);
  • }
  • }
  • return m3;
  • }
  • /**/
  • Matrix Matrix::operator*(Matrix mat2)
  • //Matrix multiplication(Matrix m1,Matrix mat2)
  • {
  • Matrix m3(nbr_lig,nbr_col);
  • if(nbr_lig==mat2.nbr_lig)
  • {
  • int i,j,k,w;
  • for(i=1;i<=nbr_lig;i++)
  • for(j=1;j<=mat2.nbr_col;j++)
  • {
  • w=0;
  • for(k=1;k<=nbr_col;k++)
  • w+=extraire(i,k)*mat2.extraire(k,j);
  • m3.lecture(i,j,w);
  • }
  • }
  • else {
  • alarma();
  • cout<<"Les matrice ne sont pas egaux au niveau de la dimension ";
  • delay(2000);nosound();}
  • return m3;
  • }
  • /**/
  • void main()
  • {
  • int s,x,y,z,lig;
  • element* ptr;
  • int max_lig=3;
  • int max_col=3;
  • Matrix mat1(max_lig,max_col),mat2(max_lig,max_col),mat3(max_lig,max_col);
  • char c='r',rep;
  • clrscr();
  • while(c!='6')
  • {
  • rep='r';
  • c=menu_prince();
  • switch(c)
  • {
  • case'1':{
  • while(rep!='3')
  • {
  • rep=menu_lecture();
  • switch(rep)
  • {
  • case '1':{ int toto=0;
  • cout<<"  Remplissage Mat1 \n";
  • cout<<"  "<<max_lig<<" * "<<max_col<<" \n";
  • gotoxy(5,3+toto);
  • cout<<"LIGNES";
  • gotoxy(25,3+toto);
  • cout<<"COLONNES";
  • gotoxy(45,3+toto);
  • cout<<"VALEURS";
  • while(s)
  • {
  • gotoxy(5,6+toto);
  • cin>>x;
  • if(x&&x<=max_lig)
  • {
  • gotoxy(25,6+toto);
  • cin>>y;
  • if(!y||y>max_col)
  • {
  • alarma();
  • break;
  • }
  • gotoxy(45,6+toto);
  • cin>>z;
  • mat1.lecture(x,y,z);
  • toto++;
  • }
  • else
  • {
  • alarma();
  • s=0;
  • }
  • }
  • s=1;
  • break;
  • }
  • case'2':{
  • cout<<"  Remplissage Mat2 \n";
  • cout<<"  "<<max_lig<<" * "<<max_col<<" \n";
  • int toto=0;gotoxy(5,2+toto);
  • cout<<"LIGNES";
  • gotoxy(25,2+toto);
  • cout<<"COLONNES";
  • gotoxy(45,2+toto);
  • cout<<"VALEURS";
  • while(s)
  • {
  • gotoxy(5,6+toto);
  • cin>>x;
  • if(x&&x<=max_lig)
  • {
  • gotoxy(25,6+toto);
  • cin>>y;
  • if(!y||y>max_col)
  • {
  • alarma();
  • break;
  • }
  • gotoxy(45,6+toto);
  • cin>>z;
  • mat2.lecture(x,y,z);
  • toto++;
  • }
  • else
  • {
  • alarma();
  • s=0;
  • }
  • }
  • break;}
  • }
  • }
  • break;
  • }
  • case '2':{
  • rep=menu_extraire();
  • cout<<"  EXTRAIRE ELEMENT \n";
  • cout<<"  "<<max_lig<<" * "<<max_col<<" \n";
  • switch (rep)
  • {
  • case '1':
  • {
  • int toto=0;gotoxy(5,2+toto);
  • cout<<"LIGNES";
  • gotoxy(25,2+toto);
  • cout<<"COLONNES";
  • gotoxy(45,2+toto);
  • cout<<"VALEURS";
  • s=1;
  • while(s)
  • {
  • gotoxy(5,6+toto);
  • cin>>x;
  • if(x&&x<=max_lig)
  • {
  • gotoxy(25,6+toto);
  • cin>>y;
  • if(!y||y>max_col)
  • {
  • alarma();
  • break;
  • }
  • else
  • {
  • gotoxy(45,6+toto);
  • cout<<mat1.extraire(x,y);
  • }
  • toto++;
  • }
  • else
  • {
  • alarma();
  • s=0;
  • }
  • }
  • }
  • break;
  • case '2':
  • {
  • int toto=0;gotoxy(5,2+toto);
  • cout<<"LIGNES";
  • gotoxy(25,2+toto);
  • cout<<"COLONNES";
  • gotoxy(45,2+toto);
  • cout<<"VALEURS";
  • s=1;
  • while(s)
  • {
  • gotoxy(5,6+toto);
  • cin>>x;
  • if(x&&x<=max_lig)
  • {
  • gotoxy(25,6+toto);
  • cin>>y;
  • if(!y||y>max_col)
  • {
  • alarma();
  • break;
  • }
  • else
  • {
  • gotoxy(45,6+toto);
  • cout<<mat2.extraire(x,y);
  • }
  • toto++;
  • }
  • else
  • {
  • alarma();
  • s=0;
  • }
  • }
  • }
  • break;
  • }
  • break;
  • }
  • case'3':{
  • while(rep!='4')
  • {
  • rep=menu_affichage();
  • switch(rep)
  • {
  • case'1':{mat1.afficher();
  • break;}
  • case'2':{mat2.afficher();
  • break;}
  • }
  • }
  • break;
  • }
  • case'4':{//Addition
  • mat3=mat1+mat2;
  • mat3.afficher();
  • break;
  • }
  • case'5':{
  • //Multiplication
  • mat3=mat1*mat2;
  • mat3.afficher();
  • break;
  • }
  • case '6':{
  • exit(0);
  • }
  • }
  • }
  • }
#include<dos.h>
#include<conio.h>
#include<iostream.h>
#include<stdlib.h>

class element
{
 public:
   element(int=1,int=1,int=1);
   int ligne(element*x){return x->lig;}
   int colonne(element*x){return x->col;}
   int valeur(element*x){return x->val;}
   void afctacol_suiv(element *x,element*y){x->col_suiv=y;}
   void afctalig_suiv(element *x,element*y){x->lig_suiv=y;}
   element *rtncol_suiv(element*x){return x->col_suiv;}
   element *rtnlig_suiv(element*x){return x->lig_suiv;}
   void operator delete(void *p){delete p;}
 private:
   int lig,col,val;
   element* col_suiv,*lig_suiv;
};

class Matrix:public element
{
 public:
   ~Matrix();
   Matrix(int=0,int=0);
   void afficher();
   void lecture(int,int,int);
   int extraire(int,int);
   Matrix operator+(Matrix);
   Matrix operator*(Matrix);
 private:
   int nbr_col,nbr_lig;
   element *T_col[10],*T_lig[10];
};
void alarma()
{
    unsigned frequence;
    do
    {
	for(frequence=500 ; frequence<=1500; frequence+=50)
	{
	    sound(frequence);
	    delay(10);
	}
		for(frequence=1500; frequence>=500; frequence-=50)
	{
	    sound(frequence);
	    delay(10);
	}
	}
while(! kbhit());
nosound();
}

char menu_prince()
 {
  char c;
  textcolor(14);
  clrscr();
  cout<<" MENU PRINCIPAL \n";
  gotoxy(1,10);
  cout<<" 1    )--------    Lecture\n";
  cout<<" 2    )--------    Extraction\n";
  cout<<" 3    )--------    Affichage\n";
  cout<<" 4    )--------    Addition\n";
  cout<<" 5    )--------    Multiplication\n";
  cout<<" 6    )--------    Quitter\n";
  gotoxy(1,10);textcolor(10+BLINK);cprintf(" 1");
  gotoxy(1,11);textcolor(11+BLINK);cprintf(" 2");
  gotoxy(1,12);textcolor(12+BLINK);cprintf(" 3");
  gotoxy(1,13);textcolor(10+BLINK);cprintf(" 4");
  gotoxy(1,14);textcolor(11+BLINK);cprintf(" 5");
  gotoxy(1,15);textcolor(12+BLINK);cprintf(" 6");
  gotoxy(79,24);
  textcolor(14);
  c=getch();
  clrscr();
  return c;
 }

char menu_lecture()
 {
  char c;
  textcolor(14);
  clrscr();
  cout<<" LECTURE \n";
 gotoxy(1,10);
  cout<<"1     )--------    Rempilissage de La Matrix 1 \n";
  cout<<"2     )--------    Rempilissage de La Matrix 2\n";
  cout<<"3     )--------    Retour\n";
  gotoxy(1,10);textcolor(10+BLINK);cprintf("1");
  gotoxy(1,11);textcolor(11+BLINK);cprintf("2");
  gotoxy(1,12);textcolor(12+BLINK);cprintf("3");
  gotoxy(79,24);
  textcolor(14);
  c=getch();
  clrscr();
  return c;
 }

char menu_extraire()
 {
  char c;
  textcolor(14);
  clrscr();
  cout<<" EXTRAIRE \n";
 gotoxy(1,10);
  cout<<"1     )--------    Extaire de La Matrix 1 \n";
  cout<<"2     )--------    Extaire de La Matrix 2\n";
  cout<<"3     )--------    Retour\n";
  gotoxy(1,10);textcolor(10+BLINK);cprintf("1");
  gotoxy(1,11);textcolor(11+BLINK);cprintf("2");
  gotoxy(1,12);textcolor(12+BLINK);cprintf("3");
  gotoxy(79,24);
  textcolor(14);
  c=getch();
  clrscr();
  return c;
 }


char menu_affichage()
 {
  char c;
  clrscr();
   cout<<" AFFICHAGE \n";
  gotoxy (1,10);
  cout<<"1     )--------    Afficher La Matrix 1\n";
  cout<<"2     )--------    Afficher La Matrix 2 \n";
  cout<<"3     )--------    Afficher La Matrix Resultat  \n";
  cout<<"4     )--------    Retour\n";
  gotoxy(1,10);textcolor(10+BLINK);cprintf("1");
  gotoxy(1,11);textcolor(11+BLINK);cprintf("2");
  gotoxy(1,12);textcolor(11+BLINK);cprintf("3");
  gotoxy(1,13);textcolor(12+BLINK);cprintf("4");
  gotoxy(79,24);
  textcolor(14);
  c=getch();
  clrscr();
  return c;
 }
/**/
element::element(int x,int y,int z)
{
 lig=x;
 col=y;
 val=z;
 col_suiv=NULL;
 lig_suiv=NULL;
}
/**/
Matrix::~Matrix()
{
delete(*T_col);
delete(*T_lig);
}
/**/
Matrix::Matrix(int x, int y)
{  int i;
char c;
int init_nbr_col,init_nbr_lig;
   nbr_lig=x;
   nbr_col=y;
   //initialisation du tableau colonne par NULL
   // La partie colonnes
   for(i=1;i<=y;i++)
   T_col[i]=NULL;
    // La partie lignes
    for(i=1;i<=x;i++)
    T_lig[i]=NULL;
}
/**/
void Matrix::afficher()
{
  element *ptr;
  int i,j,x,y;
  for(j=1;j<=nbr_lig;j++)
     for(i=1;i<=nbr_col;i++)
       {
	gotoxy(i*3,j*3);
	cout<<"0";
       }
    for(i=1;i<=nbr_col;i++)
     {
      ptr=T_col[i];
      while(ptr!=NULL)
       {
	y=ligne(ptr);
	x=colonne(ptr);
	gotoxy(x*3,y*3);
	cout<<valeur(ptr);
	ptr=rtncol_suiv(ptr);
       }
  }
  getch();
}
/**/
int Matrix::extraire(int x,int y)
{ int ind_lig,ind_col;
  element *ptr1,n;
  ptr1=T_col[y];
  if(ptr1)
   {
    ind_lig=n.ligne(ptr1);
    while((ptr1)&&(ind_lig!=x))
     {
      ptr1=n.rtncol_suiv(ptr1);
      ind_lig=n.ligne(ptr1);
     }
   }
  if(ptr1)return n.valeur(ptr1);
  else return 0;
}
/**/
void Matrix::lecture(int lig,int col,int val)
{
 int ind_col,ind_lig;
 element *ptrn,*ptr1,*ptr2;
 element elem;
 if(lig&&col&&val)//Pour creer un new noeud il faut tester si
 //col!=0 et val!=0 et lig!=0
 {
      ptrn=new element(lig,col,val);
      ptr1=T_col[col];//un attachement
      ptr2=ptr1;//sauvgarde
      if(ptr1)
      {
       ind_lig=elem.ligne(ptr1);
       if(ind_lig>elem.ligne(ptrn))
	{
	  T_col[col]=ptrn;
	  elem.afctacol_suiv(ptrn,ptr1);
	}
       else
	{
	  while((ptr1)&&(ind_lig<(elem.ligne(ptrn))))
	   {
	    ptr2=ptr1;
	    ptr1=elem.rtncol_suiv(ptr1);
	    ind_lig=elem.ligne(ptr1);
	   }
	  if(ind_lig==elem.ligne(ptrn))
	    {
	    elem.afctacol_suiv(ptrn,elem.rtncol_suiv(ptr1));
	    if(ptr1==T_col[col])
		    T_col[col]=ptrn;
	    else    elem.afctacol_suiv(ptr2,ptrn);
	    }
	  else
	    {
	      elem.afctacol_suiv(ptrn,elem.rtncol_suiv(ptr2));
	      elem.afctacol_suiv(ptr2,ptrn);
	    }
	}
      }
      else
       T_col[col]=ptrn;
     ptr1=T_lig[lig];
     ptr2=ptr1;
     if(ptr1)
     {
      ind_col=elem.colonne(ptr1);
      if(ind_col>elem.colonne(ptrn))
	{
	  T_lig[lig]=ptrn;
	  elem.afctalig_suiv(ptrn,ptr1);
	}
      else
	{
	  while((ptr1)&&(ind_col<(elem.colonne(ptrn))))
	  {
	   ptr2=ptr1;
	   ptr1=elem.rtnlig_suiv(ptr1);
	   ind_col=elem.colonne(ptr1);
	  }
	}
      if(ind_col==elem.colonne(ptrn))
	{
	 elem.afctalig_suiv(ptrn,elem.rtncol_suiv(ptr1));
	 if(ptr1==T_lig[lig])
		T_lig[lig]=ptrn;
	 else   elem.afctalig_suiv(ptr2,ptrn);
	}
      else
	{
	 elem.afctalig_suiv(ptrn,elem.rtncol_suiv(ptr2));
	 elem.afctalig_suiv(ptr2,ptrn);
	 }
      }
      else
       T_lig[lig]=ptrn;
 }
}
/**/
Matrix Matrix::operator+(Matrix mat2)
{
 Matrix m3(nbr_col,nbr_lig);
 int i,j,z,w;
 if((nbr_col==mat2.nbr_col)&&(nbr_lig==mat2.nbr_lig))
 {
   for(i=1;i<=nbr_lig;i++)
     for(j=1;j<=nbr_col;j++)
      {
	z=extraire(i,j);
	w=mat2.extraire(i,j);
	m3.lecture(i,j,z+w);
      }
  }
 return m3;
}
/**/
Matrix Matrix::operator*(Matrix mat2)
//Matrix multiplication(Matrix m1,Matrix mat2)
{
 Matrix m3(nbr_lig,nbr_col);
 if(nbr_lig==mat2.nbr_lig)
 {
  int i,j,k,w;
  for(i=1;i<=nbr_lig;i++)
    for(j=1;j<=mat2.nbr_col;j++)
     {
      w=0;
      for(k=1;k<=nbr_col;k++)
	w+=extraire(i,k)*mat2.extraire(k,j);
      m3.lecture(i,j,w);
    }
  }
  else {
	alarma();
	cout<<"Les matrice ne sont pas egaux au niveau de la dimension ";
	delay(2000);nosound();}
return m3;
}
/**/
void main()
{
 int s,x,y,z,lig;
 element* ptr;
 int max_lig=3;
 int max_col=3;
 Matrix mat1(max_lig,max_col),mat2(max_lig,max_col),mat3(max_lig,max_col);
 char c='r',rep;
 clrscr();
 while(c!='6')
 {
  rep='r';
  c=menu_prince();
  switch(c)
  {
    case'1':{
	     while(rep!='3')
	     {
	      rep=menu_lecture();
	      switch(rep)
	      {
		case '1':{ int toto=0;
cout<<"             Remplissage Mat1 \n";
cout<<"               "<<max_lig<<" * "<<max_col<<"   \n";
				     gotoxy(5,3+toto);
				     cout<<"LIGNES";
				     gotoxy(25,3+toto);
				     cout<<"COLONNES";
				     gotoxy(45,3+toto);
				     cout<<"VALEURS";
				while(s)
			 {
			  gotoxy(5,6+toto);
			  cin>>x;
			     if(x&&x<=max_lig)
			   {
			    gotoxy(25,6+toto);
			    cin>>y;
			    if(!y||y>max_col)
			     {
			     alarma();
			     break;
			     }
			    gotoxy(45,6+toto);
			    cin>>z;
			    mat1.lecture(x,y,z);
			   toto++;
			   }
			   else
			   {
			   alarma();
			   s=0;

			  }
			  }
			 s=1;
			 break;
			 }

		case'2':{
cout<<"             Remplissage Mat2 \n";
cout<<"               "<<max_lig<<" * "<<max_col<<"   \n";

			 int toto=0;gotoxy(5,2+toto);
			 cout<<"LIGNES";
			 gotoxy(25,2+toto);
			 cout<<"COLONNES";
			 gotoxy(45,2+toto);
			 cout<<"VALEURS";
			 while(s)
			 {
			  gotoxy(5,6+toto);
			  cin>>x;
			    if(x&&x<=max_lig)
			   {
			    gotoxy(25,6+toto);
			    cin>>y;
			    if(!y||y>max_col)
			    {
			    alarma();
			    break;
			    }
			    gotoxy(45,6+toto);
			    cin>>z;
			    mat2.lecture(x,y,z);
			   toto++;
			   }
			   else
			   {
			   alarma();
			   s=0;
			   }
			  }
			 break;}
	      }
	     }
	     break;
	    }
case '2':{
rep=menu_extraire();
cout<<"             EXTRAIRE ELEMENT \n";
cout<<"               "<<max_lig<<" * "<<max_col<<"   \n";
  switch (rep)
  {
  case '1':
  {
   int toto=0;gotoxy(5,2+toto);
   cout<<"LIGNES";
   gotoxy(25,2+toto);
   cout<<"COLONNES";
   gotoxy(45,2+toto);
   cout<<"VALEURS";
   s=1;
   while(s)
   {
   gotoxy(5,6+toto);
   cin>>x;
   if(x&&x<=max_lig)
   {
   gotoxy(25,6+toto);
   cin>>y;
   if(!y||y>max_col)
   {
   alarma();
   break;
   }
   else
   {
   gotoxy(45,6+toto);
   cout<<mat1.extraire(x,y);
   }
   toto++;
   }
   else
   {
   alarma();
   s=0;
   }
   }
}
break;
  case '2':
  {
   int toto=0;gotoxy(5,2+toto);
   cout<<"LIGNES";
   gotoxy(25,2+toto);
   cout<<"COLONNES";
   gotoxy(45,2+toto);
   cout<<"VALEURS";
   s=1;
   while(s)
   {
   gotoxy(5,6+toto);
   cin>>x;
   if(x&&x<=max_lig)
   {
   gotoxy(25,6+toto);
   cin>>y;
   if(!y||y>max_col)
   {
   alarma();
   break;
   }
   else
   {
   gotoxy(45,6+toto);
   cout<<mat2.extraire(x,y);
   }
   toto++;
   }
   else
   {
   alarma();
   s=0;
   }
   }
}
break;
}
break;
}
    case'3':{
	     while(rep!='4')
	     {
	      rep=menu_affichage();
	      switch(rep)
	      {
		case'1':{mat1.afficher();
			break;}
		case'2':{mat2.afficher();
			break;}
	      }
	     }
	    break;
	    }
    case'4':{//Addition
	     mat3=mat1+mat2;
	     mat3.afficher();
	    break;
	    }
    case'5':{
	    //Multiplication
	    mat3=mat1*mat2;
	    mat3.afficher();
	    break;
	    }
   case '6':{
	     exit(0);
	     }
  }
 }
} 


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

05 décembre 2007 08:37:26 :
Mise a jour du titre et de la description

 Sources du même auteur

Source avec Zip CALCULATRICE SCIENTIFIQUE AVEC LE LIBELLE VERSION 2
Source avec Zip CALCULATRICE EN VISUAL C++ EN ATTANDANT DES AMÉLIORATION
Source avec une capture CONVERTISSEUR DE CHIFFRES ROMAIN AU CHIFFRE DÉCIMALE
MENU DEROULANT ANSI C
SIMULATION DE LA MEMOIRE AVEC LA PAGINATION DE 1000 PAGES [T...

 Sources de la même categorie

Source avec Zip UN EXAMPLE D'APPLICATION EN CUDA DE L'ALGORITHME DE SCAN POU... par oguzaras
Source avec Zip Source avec une capture CHIFFREMENT DE VIGENERE par lajouad
Source avec Zip Source avec une capture ANALYSE SYNTAXIQUE par lajouad
Source avec Zip Source avec une capture STRUCTURE D'UNE MATRICE PAR LES LISTE LINÉAIRE (NON CONTUGUS... par benzarabel
Source avec Zip Source avec une capture DESSINER UNE ARBRE BINAIRE( MODE CONSOLE): par benzarabel

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture JEU PUISSANCE 4 EN C AVEC GTK par msaidara
Source avec Zip GENERIC INPUTBOX FOR WINDOWS (WIN32 AND C) par FrancoisGauthier
Source avec Zip ENTETE DU FICHIER BMP (BIPMAP) par k.Lutchi
Source avec Zip Source avec une capture OP4 UN INTERPRÉTEUR POUR ENTIERS DE TRÈS GRANDE TAILLE par pgl10
Source avec Zip WINDOWCAPTURE par FrancoisGauthier

Commentaires et avis

Commentaire de Jo le 08/02/2002 12:04:04

Bon ! Je vois qui faut qu je recommence a gueuler, pour que le nom du compilateur apparaisse quelques part alors puisque c'est ca:

LA NOM DU COMPILATEUR DANS LE TITRE DE LA SOURCE OU  AU DESSUS DU CODE !!!!!!!!!

Commentaire de belhauss le 05/12/2007 00:43:31 1/10

hééhéééééé c t 1 Marocain wach tu raconte bro avec lghorba ?? j m'excuse mai je dois gueuler comême :) MAI IL EST OU LE NOM DU COMPILATEUR !!!!!!!!!

Commentaire de hamdan le 05/12/2007 08:28:57

c'est un TurboC version 3

Commentaire de belhauss le 05/12/2007 16:00:11

mdr j vien de voir le Nom du notre Super prof :D cooooooooool
wé merçi j ai arrivé a le compiler mai c pa du tt ce ke je cherche j pense que je dois me mettre au travail .chokran :)

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,997 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales