All pastes #807393 Raw Edit

Etwas

public text v1 · immutable
·published 2007-12-06 17:42 UTC
rendered paste body
static int Berechne(ref int n, ref int k, out int binom_koeff)
{
	int fakultät_n = 1;
	int fakultät_k = 1;
	int fakultät_h = 1;
	int h;
	h = n - k;

	for(int i = n; i >= 2; i--)
	{
		fakultät_n *= i;
	}
	for(int j = k; j >= 2; j--)
	{
		fakultät_k *= j;
	}
	for(int l = h; l >= 2; l--)
	{
		fakultät_h *= l;
	}

	binom_koeff = fakultät_n / (fakultät_k * fakultät_h);

	return binom_koeff;

}

  // Einstiegsmethode

static void Main()
{
string ausgabe;
//Anzahl der Kugeln
int n;
//Zu ziehende Kugeln
int k;
//Binominialkoeffizient
int binom_koeff;

//Einlesen der Gesamtzahl
n = GanzzahlWert(EingabeVonKonsole("Gesamtzahl der Kugeln?:"));

//Einlesen der zu ziehenden Kugeln
k = GanzzahlWert(EingabeVonKonsole("Anzahl der zu ziehenden Kugeln"));

Berechne(ref n,ref k,out binom_koeff);

ausgabe = "Es gibt " + Zeichenkette(binom_koeff) + " verschiedene Möglichkeiten";

AusgebenAufKonsole(ausgabe);

}