I am assigned to develop a multiplication table using 2D Arrays and Nested loops. The teacher gave us a starting form/etc, but I just dont know where to start! 2 dimensional arrays really threw me for a loop (no pun intended). Can anyone help get me started?
I have attached the startup form, etc. Here are the class requirements:
- A two dimensional array has been declared in the program as: int [ , ] intTable = new int[9,9]; // 9 x 9 table
- Students are to develop the method that loads the multiplication table into the array using nested loops. Use intTable.GetLength(0) to go down the table and intTable.GetLength(1) to go across.
- Students are to develop the method that displays the array after it has been loaded with the multiplication table using nested loops.
- Students are to develop the method that searches the array for all occurrences of the number entered as the search criteria in the textbox. Again, use nested loops.
How shall I start this one?
edmund durangoPosted Jul 21, 2012, 2:12 AM
i will try this in my school....
Ryan KrenzPosted Apr 21, 2012, 3:26 PM
VulpesPosted Apr 21, 2012, 2:17 PM
Ryan KrenzPosted Apr 21, 2012, 1:11 PM
private void btnDisplayArray_Click(object sender, EventArgs e)
{
int r; //row
int c; //column
string strSpace;
txtTable.Clear(); //clear the text box
r = 0;
while (r < 8)
{
r++;
c = 0;
while (c < 8)
{
c++;
if (intTable[r, c] < 10)
strSpace = " "; //two spaces
else
strSpace = " "; //one space
txtTable.AppendText(strSpace); // insert space
txtTable.AppendText(intTable[r, c].ToString()); //insert result
}
txtTable.AppendText("\r\n"); //Move down one line
}
}
Ryan KrenzPosted Apr 21, 2012, 1:08 PM
Also, I could use a hint on the "search" function.
Here is my code for the "display", what am I missing?
I also attached my updated project.
THank you!
VulpesPosted Apr 19, 2012, 5:05 AM