TP 7: Boucles imbriquées et matrices
#include <iostream> using namespace std; int main(int argc, char* const argv[]){ int m,n; cin >> m >> n; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) cout << "X"; cout << endl; } return 0; }
#include <iostream> using namespace std; const int m=10,n=5; int main(int argc, char* const argv[]){ int a,b,k,i,j; int matrice[m][n]; k=1; for (i = 0; i < m; i++) for (j = 0; j < n; j++) { matrice[i][j]=k; k++; } cin>>a>>b; if (a<m and b<n) cout<<matrice[a][b]; return 0; }
n
et qui affiche ensuite à l'écran toutes les paires n
lignes de la façon suivante:
Rappel : une matrice (
de
à
,
de
à
)
est dite symétrique si elle est égale à sa transposée, c'est-à-dire
si :