diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Bachelor/Prog1/Prakt3/prg1p3_2/main.cpp | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Bachelor/Prog1/Prakt3/prg1p3_2/main.cpp')
| -rw-r--r-- | Bachelor/Prog1/Prakt3/prg1p3_2/main.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/Bachelor/Prog1/Prakt3/prg1p3_2/main.cpp b/Bachelor/Prog1/Prakt3/prg1p3_2/main.cpp new file mode 100644 index 0000000..35796d5 --- /dev/null +++ b/Bachelor/Prog1/Prakt3/prg1p3_2/main.cpp @@ -0,0 +1,81 @@ +// 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 <iostream>
+using std::cin;
+using std::cout;
+using std::endl;
+
+#include <ctime>
+#include <cstdlib>
+
+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)));
+}
\ No newline at end of file |
