Matrice en C++
etudiantmaster
-
Char Snipeur Messages postés 10112 Date d'inscription Statut Contributeur Dernière intervention -
Char Snipeur Messages postés 10112 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
j'ai développe un petit programme C++ qui permet d'afficher une matrice.J'ai utilisé la classe vector pour représenter cette matrice .Mais,j'ai pas compris pourquoi lorsque j'exécute le programme ça marche pas.
voila mon petit code C++:
#include <cstdlib>
#include <iostream>
#include<vector>
#include <conio.h>
using namespace std;
class DynMatrix
{
public:
vector < vector <double> > V;
DynMatrix(int,int);
~DynMatrix();
void affiche();
};
DynMatrix::DynMatrix(int nbrow,int nbcol)
{
V.resize(nbcol);
for (int i=0;i<V.size();i++)
{
V[i].resize(nbrow+1);
}
}
void DynMatrix::affiche()
{
for (int i=1;i<=V.size();i++)
{
vector <double> inter;
inter=V[i];
for(int j=1;j<=inter.size(); j++)
{
cout <<V[i][j]<<"\t";
}
cout<<" \n";
}
}
int main(int argc, char *argv[])
{
DynMatrix *M;
M=new DynMatrix(5,5);
M->affiche();
getch();
system("PAUSE");
return EXIT_SUCCESS;
}
Merci de me répondre dans le temps le plus proche.
Merci d'avance.
j'ai développe un petit programme C++ qui permet d'afficher une matrice.J'ai utilisé la classe vector pour représenter cette matrice .Mais,j'ai pas compris pourquoi lorsque j'exécute le programme ça marche pas.
voila mon petit code C++:
#include <cstdlib>
#include <iostream>
#include<vector>
#include <conio.h>
using namespace std;
class DynMatrix
{
public:
vector < vector <double> > V;
DynMatrix(int,int);
~DynMatrix();
void affiche();
};
DynMatrix::DynMatrix(int nbrow,int nbcol)
{
V.resize(nbcol);
for (int i=0;i<V.size();i++)
{
V[i].resize(nbrow+1);
}
}
void DynMatrix::affiche()
{
for (int i=1;i<=V.size();i++)
{
vector <double> inter;
inter=V[i];
for(int j=1;j<=inter.size(); j++)
{
cout <<V[i][j]<<"\t";
}
cout<<" \n";
}
}
int main(int argc, char *argv[])
{
DynMatrix *M;
M=new DynMatrix(5,5);
M->affiche();
getch();
system("PAUSE");
return EXIT_SUCCESS;
}
Merci de me répondre dans le temps le plus proche.
Merci d'avance.
A voir également:
- Matrice en C++
- Excel vous ne pouvez pas modifier une partie de matrice ✓ - Forum Excel
- Vous ne pouvez pas modifier une partie de matrice - Forum Excel
- Inverse matrice excel ✓ - Forum Excel
- Matrice en c ✓ - Forum C
- Calculatrice matrice - Télécharger - Calcul & Conversion
this application has requested the Runtime to terminate it in an usual way.
et avant ce message, s'affiche une matrice (4,6)