salut à tous
je suis bloqué dans l'écriture de l'algo de gauss jordan.
J'ai qlqs soucis pour la procédure de réduction, voila ce que j'ai écrit :
void soustraire (matrice tab ,int n, int p, int l,int i, double b)
{
cout
#include
using namespace std;
const int NMAX=100;
typedef double matrice[NMAX][NMAX];
void remplissage (matrice tab, int &n, int &p)
{
int i=0;
int j=0;
float val;
n=0;
p=0;
cout>p;
cout>n;
for ((i=0);(i>val;
tab[i][j]=val;
}
}
}
void affichage (matrice tab ,int n, int p)
{
int i,j;
cout<<"Votre matrice : "<<endl;
for ((i=0);(i<n);i++)
{
for ((j=0);(j<p);j++)
{
cout<<tab[i][j]<<"\t";
}
cout<<endl;
cout<<endl;
}
_getche() ;
}
void intervertir (matrice tab, int n, int p, int k, int i)
{
int z;
double stock;
cout<<"*intervertion de lignes.*"<<endl;
for((z=0);(z<n);z++)
{
stock=tab[i][z];
tab[i][z]=tab[k][z];
tab[k][z]=stock;
}
affichage(tab,n,p);
_getche() ;
}
void multiplier (matrice tab, int n, int p, int i, int j, double &b)
{
int z;
cout<<"*multiplication de lignes.*"<<endl;
b=(1/tab[i][j]);
for((z=0);(z<n);z++)
{
tab[i][z]=tab[i][z]*b;
}
affichage(tab,n,p);
_getche() ;
}
void soustraire (matrice tab ,int n, int p, int l,int i, double b)
{
cout<<"*soustraction de lignes*."<<endl;
int z;
for((z=0);(z<n);z++)
{
tab[l][z]=tab[l][z]-((tab[i][z])*b);
}
affichage(tab,n,p);
_getche() ;
}
void reduite(matrice tab,int n, int p, int &k, int &i, int &j, int &l, double b)
{
i=0;
j=0;
while ((i<n)&&(j<p))
{
k=i;
while ((k<n)&&(tab[k][j]==0))
{
k++;
}
if (i<n)
{
if (i!=k)
{
intervertir(tab,n,p,k,i);
}
multiplier(tab,n,p,i,j,b);
for ((l=0);(l<i);l++)
{
soustraire(tab,n,p,l,i,b);
}
for ((l=(k+1));(l<n);l++)
{
soustraire(tab,n,p,l,i,b);
}
i++;
}
j++;
}
affichage(tab,n,p);
_getche() ;
}
void main ()
{
double b;
b=1;
int n,p;
int k,i,j,l;
matrice tab;
remplissage(tab,n,p);
affichage(tab,n,p);
cout<<"La matrice va etre reduite..."<<endl;
_getche() ;
reduite(tab,n,p,k,i,j,l,b);
_getche() ;
_getch () ;
}
voila merci d'avance si vous pouvez m'aider.
