#include #include "tableaux.h" using namespace std; // Fonction 0 unsigned int saisie_entiers( unsigned int taille_reelle, unsigned int tab[] ) { unsigned int i = 0; int saisie; cout << "Saisir jusqu'a " << taille_reelle << " entiers positifs. Terminer la saisie par -1" << endl; do { cin >> saisie; if (saisie != -1) { tab[i] = saisie; i++; } } while (saisie != -1 && i < taille_reelle); return i; } // Fonction 1 void copie( const unsigned int tab_in[], unsigned int tab_out[], unsigned int taille_pratique_in, unsigned int taille_reelle_out ) { if (taille_pratique_in <= taille_reelle_out) { for (unsigned int i = 0; i < taille_pratique_in; i++) { tab_out[i] = tab_in[i]; } } } // Fonction 2 void afficher_tableau( const unsigned int tab[], unsigned int taille_pratique ) { unsigned int i = 0; cout << "{" << tab[i]; for (i = 1; i+1 < taille_pratique; i++) { cout << "," << tab[i]; } cout << "}"; } // Fonction 3 bool sont_identiques( const unsigned int tab1[], const unsigned int tab2[], unsigned int taille_pratique1, unsigned int taille_pratique2 ) { if (taille_pratique1 != taille_pratique2) { return false; } for (unsigned int i = 0; i < taille_pratique1; i++) { if (tab1[i] != tab2[i]) { return false; } } return true; } // Fonction 4 float moyenne_tableau( const unsigned int tab[], unsigned int taille_pratique ) { int somme = 0; for (unsigned int i = 0; i < taille_pratique; i++) { somme += tab[i]; } return (float)somme/taille_pratique; } // Fonction 5 void somme_cumulee( unsigned int tab[], unsigned int taille_pratique ) { int somme; for (unsigned int i = 0; i < taille_pratique; i++) { somme = 0; for (unsigned int j = 0; j <= i; i++) { somme += tab[j]; } tab[i] = somme; } }