// ------------------------------------------------------------------ // Cas d'une matrice de float allouée dynamiquement // ------------------------------------------------------------------ #include #include using namespace std; int main( int argc, char *argv[] ) { // création d'une matrice de 3 lignes par 7 colonnes de float float **m; m = new float * [ 3 ]; for (int i = 0; i < 3; ++i) { m[ i ] = new float [ 7 ]; for (int j = 0; j < 7; ++j) { m[ i ][ j ] = i*10 + j; } } // affichage de la matrice for (int i = 0; i < 3; ++i) { for (int j = 0; j < 7; ++j) { cout << std::fixed << setw(5) << setprecision(2); cout << m[ i ][ j ] << " "; } cout << endl; } cout << **m << endl; cout << **(m + 1) << endl; cout << **(m + 2) << endl; cout << *(*(m+2) + 3) << endl; return EXIT_SUCCESS; }