Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed APDS_9960 mbed-rtos
Diff: src/cMatrice.cpp
- Revision:
- 33:a6f0be429ce0
- Parent:
- 32:029962133529
--- a/src/cMatrice.cpp Fri Apr 22 06:29:56 2016 +0000
+++ b/src/cMatrice.cpp Fri Apr 22 08:18:46 2016 +0000
@@ -10,13 +10,13 @@
}
//Constructeur qui crée une matrice de l lignes sur c colonnes
-cMatrice::cMatrice(int l, int c)
+cMatrice::cMatrice(int c, int l)
{
_lig = l;
_col = c;
- _matrice = new int*[_lig];
- for(unsigned int i = 0; i < _lig; i++) {
- _matrice[i] = new int[_col];
+ _matrice = new int*[_col];
+ for(unsigned int i = 0; i < _col; i++) {
+ _matrice[i] = new int[_lig];
}
clear();
}
@@ -24,16 +24,16 @@
// DESTRUCTEUR
cMatrice::~cMatrice()
{
- for(int i = 0; i < _lig; i++) {
+ for(int i = 0; i < _col; i++) {
delete[] _matrice[i];
delete[] _matrice;
}
}
// GETTER
-int cMatrice::getValTab(int l, int c)
+int cMatrice::getValTab(int c, int l)
{
- return _matrice[l][c];
+ return _matrice[c][l];
}
int cMatrice::getCol()
@@ -61,9 +61,9 @@
{
_lig = l;
}
-void cMatrice::setValTab(int l, int c, unsigned int coul)
+void cMatrice::setValTab(int c, int l, unsigned int coul)
{
- _matrice [l][c] = coul;
+ _matrice [c][l] = coul;
}
// METHODES
@@ -95,9 +95,9 @@
// Nettoyage de la matrice, passage à 0 de la valeur de chaque Led
void cMatrice::clear()
{
- for( int i = 0; i < _lig; i++) {
- for( int j = 0; j < _col; j++) {
- _matrice[j][i] = LED_NOIR;
+ for( int i = 0; i < _col; i++) {
+ for( int j = 0; j < _lig; j++) {
+ _matrice[i][j] = LED_NOIR;
}
}
//////////////////////////////////////////////////////////////////////////////////////