[ Pobierz całość w formacie PDF ]
.// Fig// Fig.4.11: fig04_11.cpp// Roll a six-sided die 6000 times#include <iostream.h>#include <iomanip.h>#include <stdlib.h>#include <time.h>int main(){const int arraySize = 7;int face, frequency[ arraySize ] = { 0 };srand( time( 0 ) );for ( int roll = 1; roll <= 6000; roll++ )++frequency[ 1 + rand() % 6 ]; // replaces 20-line switch// of Fig.3.8cout << "Face" << setw( 13 ) << "Frequency" << endl;// ignore element 0 in the frequency arrayfor ( face = 1; face < arraySize ; face++ )cout << setw( 4 ) << face<< setw( 13 ) << frequency[ face ] << endl;return 0;} [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • centka.pev.pl
  •