|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
UNE MATRICE CREUSE EN TURBOC
Information sur la source
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
Pour les "Membres Club", vous pouvez 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
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version
|