/* #include #include using namespace std; // Fonction pour calculer la somme des N premiers éléments d'un tableau int SOMME_TAB( int Tab ,int n) { int somme = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { somme += Tab[i][j]; } } return somme; } int main() { int n; cout << "n="; cin >> n; int Tab[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { Tab[i][j] = pow(n, i * j); } } // Affichage des éléments du tableau cout << "Tableau rempli avec les puissances de " << n << "^(i*j):" << endl; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cout << "tab[" << i << "][" << j << "] = " << Tab[i][j] << endl; } } int somme = SOMME_TAB(Tab, n ); // Affichage de la somme std::cout << "La somme des elements du tableau est : " << somme << std::endl; return 0; } */ /* #include #include using namespace std; // Fonction pour calculer la somme des éléments d'un tableau int SOMME_TAB(int Tab[], int n) { int somme = 0; for (int i = 0; i < n; i++) { somme += Tab[i]; } return somme; } int main() { int n; cout << "n="; cin >> n; int Tab[n]; for (int i = 0; i < n; i++) { Tab[i] = pow(n, i); } // Affichage des éléments du tableau for (int i = 0; i < n; i++) { cout << "Tab[" << i << "] = " << Tab[i] << endl; } int somme = SOMME_TAB(Tab, n); // Affichage de la somme cout << "La somme des elements du tableau est : " << somme << endl; return 0; } */ /* #include using namespace std; // Fonction f(x) = x^3 - 2x int f(int x) { return x * x * x - 2 * x; } int main() { cout << "Table de valeurs de la fonction f(x) = x^3 - 2x pour x de 1 à 10 :\n"; cout << "---------------------------------------------\n"; cout << "| x | f(x) = x^3 - 2x |\n"; cout << "---------------------------------------------\n"; for (int x = 1; x <= 10; ++x) { cout << "| " << x << " | " << f(x) << " |\n"; } cout << "---------------------------------------------\n"; return 0; } */ #include using namespace std; const int MAX_ROWS = 3; // Définir le nombre maximal de lignes pour les matrices const int MAX_COLS = 3; // Définir le nombre maximal de colonnes pour les matrices // Fonction pour additionner deux matrices MAT1 et MAT2 et stocker le résultat dans MAT3 void ADDITION_MATRICE(int MAT1[][MAX_COLS], int MAT2[][MAX_COLS], int MAT3[][MAX_COLS]) { for (int i = 0; i < MAX_ROWS; ++i) { for (int j = 0; j < MAX_COLS; ++j) { MAT3[i][j] = MAT1[i][j] + MAT2[i][j]; } } } // Fonction pour afficher une matrice void afficherMatrice(int MAT[][MAX_COLS]) { for (int i = 0; i < MAX_ROWS; ++i) { for (int j = 0; j < MAX_COLS; ++j) { cout << MAT[i][j] << "\t"; } cout << endl; } } int main() { int MAT1[MAX_ROWS][MAX_COLS] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int MAT2[MAX_ROWS][MAX_COLS] = {{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}; int MAT3[MAX_ROWS][MAX_COLS] = {}; // Ajout des deux matrices ADDITION_MATRICE(MAT1, MAT2, MAT3); // Affichage des matrices cout << "Matrice MAT1 :\n"; afficherMatrice(MAT1); cout << "\nMatrice MAT2 :\n"; afficherMatrice(MAT2); cout << "\nRésultat de l'addition (Matrice MAT3 = MAT1 + MAT2) :\n"; afficherMatrice(MAT3); return 0; }