#include using std::cout; using std::cin; using std::endl; #include using std::setw; #include // contains function prototype for rand #include // contains prototype for function time #include "sortArray.h" int main() { cout << " Dimmi il massimo numero casuale che vuoi generare "; int randomMax; cin >> randomMax; const int freqsize = randomMax + 1; int frequency[ freqsize ]; for (int i = 0; i < freqsize; i++) frequency[ i ] = 0; // randomize random number generator using current time srand( time( 0 ) ); cout << " Dimmi la dimensione dell'Array di numeri casuali "; int dimensione; cin >> dimensione; const int responseSize = dimensione; // size of array responses int response[ responseSize ]; // initialize array responses for (int j = 0; j < responseSize; j++) response [ j ] = 1 + rand() % randomMax; //random number from 0 to freqsize // stampa la matrice printArray( response, responseSize ); cout << endl; // process responses cout << " La media: " << media(response, responseSize) << endl; cout << " La mediana: " << mediana(response, responseSize) << endl; cout << " La moda: " << moda(frequency, response, responseSize, freqsize) << endl; cout << endl << " Ecco l'istogramma delle frequenze:" << endl; printHisto( frequency, freqsize ); return 0; // indicates successful termination } // end main