|
« Antwort #25 am: 13.12.2009, 18:43:02 » |
|
Programm:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
int main ()
{
int augen, anzahl;
int augenzahl;
srand ( time(NULL) );
std::cin >> anzahl;
std::cout << std::endl;
int a;
while (anzahl > a)
{
augen = rand() % 6 + 1;
a+=1;
if (augen == 1)
{
augenzahl=1;
}
/** else if (augen == 2)
{
augenzahl[2] += 1;
}
else if (augen == 3)
{
augenzahl[3] += 1;
}
else if (augen == 4)
{
augenzahl[4] += 1;
}
else if (augen == 5)
{
augenzahl[5] +=1 ;
}
else if (augen == 6)
{
augenzahl[6] += 1;
}**/
else std::cout << "Ein Fehler ist aufgetreten, Das Programm wird beendet" << std::endl;
}
std::cout << "1 "; printf("%d", augenzahl); std::cout << std::endl;
/**std::cout << "2 " << augenzahl[2] << std::endl;
std::cout << "3 " << augenzahl[3] << std::endl;
std::cout << "4 " << augenzahl[4] << std::endl;
std::cout << "5 " << augenzahl[5] << std::endl;
std::cout << "6 " << augenzahl[6] << std::endl;**/
std::cout << "Das Programm wurde erfolgreich ausgeführt.";
return 0;
}
hab ich schon was schönes ausgeklammert. rein theoretisch müsste die Variable "Augenzahl" ordentlich als "1" ausgegeben werden, weil (bei einer Wiederholrate von 121 oder so) MUSS fast schon einmal die 1 gewürfelt werden. ausgabe ist allerdings: "4246854"