// Programmieren 1, Praktikum 3, Aufgabe 2 // Sven Eisenhauer // 12.11.2004 // // file: main.cpp // // purpose: roll 2 dice 6000 times and build a table, how often each possible sum occured // // // // #include using std::cin; using std::cout; using std::endl; #include #include int rollDice(void); int main () { int stats[13] = {0}; srand(time(0)); for (int Counter=0;Counter <= 6000;Counter++) { /* switch (rollDice()) { case 2: stats[0]++; break; case 3: stats[1]++; break; case 4: stats[2]++; break; case 5: stats[3]++; break; case 6: stats[4]++; break; case 7: stats[5]++; break; case 8: stats[6]++; break; case 9: stats[7]++; break; case 10: stats[8]++; break; case 11: stats[9]++; break; case 12: stats[10]++; break; default: cout << "Uuups... we should never get here..."; }*/ ++stats[rollDice()]; } for (int i=2;i<=12;i++) { cout << endl << i << ": " << stats[i]; } cout << endl; return 0; } int rollDice(void) { return (( 1 + (rand() % 6)) + ( 1 + (rand() % 6))); }