salut,
je programme avec c++ sous linux.
j'utilise une class matrice avec une fonction membre qui doit me retourner une instance de cette class.
mais j'arrive pas à avoir des résultat. je vous montre là ou se trouve mon pb
le prg principal est :
#include <iostream>
using namespace std;
#include <string.h>
#include "matrice.h"
#define lch 1000
#define wch 1000
#define kch 737
int main()
{
tab t,ti,b;
matrice pe(lch,wch);
//////// Génération et inversion d'un tableau de permutation///////
tableau tt; //tt est le tableau à utiliser pour le permutation
tt.permuter(); //generer un tableau tt de permutation aleatoire
tt.afficher();
tt.invert(b); //b est le tableau de permutation inverse
//////////////// Génération et inversion d'une matrice de permutation //////
matrice pin (lch,wch); //matrice identité
pin.permu(pe,b); //matrice de permutation inverse
}
la classe matrice est :
#include <stdio.h>
#include <stdlib.h>
//#include "tableau.h"
#include <iostream.h>
using namespace std;
#define lch 1000
#define wch 1000
#define kch 737
typedef unsigned int tab[lch];
typedef unsigned char mg ;
class matrice
{
//attribute
private :
unsigned int n; // Nombre de lignes
unsigned int m; // Nombre de colonnes
unsigned char p[lch][wch];
//operators
public :
matrice(unsigned int nl, unsigned int nc);
matrice permu (matrice pe,tab t);
void inverser (tab t);
private:
void setIJ(unsigned int line, unsigned int col, unsigned int value){
this.p[line][col]=value;
}
unsigned int getIJ(unsigned int line, unsigned int col){
return this.p[line][col];
}
};
matrice::matrice(unsigned int nl, unsigned int nc)
{
this.n = nl;
this.m = nc;
//mg ma[n][m]; // allocations
int i,j;
for (int i=0; i<n; i++)
{
for(int j=0; j<m; j ++)
if (i==j) this.p[i][j]=1;
else this.p[i][j]=0;
}
}
matrice matrice :: permu(matrice pe,tab t)
{
unsigned int k;
matrice pe(lch,wch);
for (int i=0;i<lch;i++)
for(int j=0;j<wch;j++)
{ k= t[j];
pe.setIJ(i,j,this.getIJ(i,k-1));
cout<< pe.getIJ(i,j)<<" ";
}
return(pe);
}
merci de bien vouloir m'aider 