2-D Array쪽을 배우고 있는데요,
정말 너무 모르겠습니다... 아예 진짜 아무것도 모르겠어요 ㅠㅠ
우선 과제내용 자체는 link해놓았고요,
이 아래 적어놓은 코드들은 제가 한 것은 아니고, 제 친구가 한것인데 친구에게 부탁해서 받았어요.
아무래도 너무 아무것도 모른상태에서 배껴서 내기엔, 다음 LAB이 너무 걱정이 되서,
조금이라도 알고내고싶어서 이렇게 올립니다.
저 코드에 대해서 간략하게 설명좀 해주실수 있으신가요..
우선 GetLength가 무엇을 뜻하는지 궁금하네요..
그리고 for loop부분도 뭘 의미하는지 잘 모르곘네요 ㅠㅠ
너무 어려운 부탁일수도 있지만,
부탁드립니다....
namespace lab7demo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double [,] A =
{{1.0, 4.0, 5.0},
{4.0, 6.0, 7.0},
{7.0, 5.0, 7.0}};
private void button1_Click(object sender, EventArgs e)
{
string outA, outB, outC;
double[,] B = new double[A.GetLength(0), A.GetLength(0)]; //declare B
double[,] C = new double[A.GetLength(0), A.GetLength(0)];//stores result
//compute B
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
B[i, j] = 100 + A[i, j];
}
}
compMatAdd(A, B, C);
outA = CreateOutput(A);
outB = CreateOutput(B);
outC = CreateOutput(C);
richTextBox1.Text = outA;
richTextBox2.Text = outB;
richTextBox3.Text = outC;
}
string CreateOutput(double[,] someArray)
{
string msg = "";
for (int i = 0; i < someArray.GetLength(0); i++)
{
for (int j = 0; j < someArray.GetLength(1); j++)
{
msg = msg+ " " + someArray[i, j];
}
msg += "\n";
}
return msg;
}
void compMatAdd(double [,] A, double [,]B, double [,] C)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
C[i, j] = A[i, j] + B[i, j];
}
}
}
}
}