Hello,
I have writted a prog that generates the values & triangleOf Pascale.
But the thing i cannot seem to find, is how to get rid of the Console.Writlines in the middle of my code (where the values get calculated).
I am using a 1 dimensional array for this insteed (i am aware a 2 dim/jagged array would make more sence for this, but thats not the point).
I have putted the Display And Calculate Method in a for that runs trough the Array but i cannot seem to get further then that.
The Console Write line code should be in the DisplayArray1Dim method.
Regards.
using System;
namespace Triangle
{
class ConsCode
{
public void ExecuteProgram()
{
Console.Title = "Triangle";
const int AantalRijen = 10;
int[] Rij = new int[AantalRijen];
for (int i = 0; i < Rij.Length; i++)
{
BerekenArray1Dim(Rij, i);
DisplayArray1Dim(Rij, i);
}
}/*ExecuteProgram*/
private void BerekenArray1Dim(int[] Rij, int i)
{
for (i = 0; i < Rij.Length; i++)
{
int F = 1;
int teller = i;
string formatting = " ";
for (int g = Rij.Length; g > i; g--)
{
Console.Write(formatting);
}/*formatting triangle*/
Console.Write("1"); // --> should not be here
for (int j = 1; teller >= 1; j++)
{
int noemer = j;
F = F * teller / noemer; //denominator en nominator
teller--;
noemer++;
Console.Write("{0,4}", F); // --> should not be here
}
Console.WriteLine(); // --> should not be here
}
Console.WriteLine("\n\n"); // --> should not be here
}/*BerekenArray1Dim*/
private void DisplayArray1Dim(int[] Rij, int i)
{
//Console WriteLines should be here in this method
}/*DisplayArray1Dim*/
}/*ConsCode*/
}