1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| using namespace sf;
Shape trace(double x, double y)
{
Shape ligne;
ligne.AddPoint(x + (600/21) - 1, 600, Color(255, 255, 0), Color(255, 255, 255));
ligne.AddPoint(x + (600/21) + 1, 600, Color(255, 255, 0), Color(255, 255, 255));
ligne.AddPoint(x + (600/21) + 1, 600 - (y + 100), Color(255, 255, 0), Color(255, 255, 255));
ligne.AddPoint(x + (600/21) - 1, 600 - (y + 100), Color(255, 255, 0), Color(255, 255, 255));
ligne.EnableFill(false);
ligne.EnableOutline(false);
ligne.SetOutlineWidth(1);
return (ligne);
}
double opt2(int n, double p)
{
double res;
int k = -1;
RenderWindow app(VideoMode(600, 600, 32), "203Poisson");
while (app.IsOpened())
{
Event event;
while (app.GetEvent(event))
{
if (event.Type == Event::Closed)
app.Close();
}
app.Clear();
while (++k < 21)
{
res = (opt1(n, k) * pow(p, k) * pow((1 - p), (n - k))); // formule renvoyant un double
app.Draw(trace(k, res));
app.Display();
}
}
return (res);
} |
Partager